标题要长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了标题要长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长相关的知识,希望对你有一定的参考价值。
1.这是一个排球比赛的作业
废话不多说直接上成果:
两张图片是在同一个页面上,修改查看在一起,简单粗暴。
具体代码实现:
ViewController.m
#import "ViewController.h"
#import "XMGTg.h"
#import "MJExtension.h"
#import "YNTableViewCell.h"
@interface ViewController ()
@property (nonatomic, strong) NSArray *tgs;
@end
@implementation ViewController
- (NSArray *)tgs
{
if (!_tgs) {
_tgs = [XMGTg mj_objectArrayWithFilename:@"tgs.plist"];
}
return _tgs;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.rowHeight = 80;
}
#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tgs.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"tg";
// 访问缓存池
YNTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (cell==nil) {
cell=[[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([YNTableViewCell class]) owner:nil options:nil]lastObject];
}
cell.tg = self.tgs[indexPath.row];
return cell;
}
@end
模型.h文件
#import <Foundation/Foundation.h>
@interface XMGTg : NSObject
@property (nonatomic, copy) NSString *duiwu1;
@property (nonatomic, copy) NSString *duiwu2;
@property (nonatomic, copy) NSString *defen1;
@property (nonatomic, copy) NSString *defen2;
@end
TableViewCell.m
#import "YNTableViewCell.h"
#import "XMGTg.h"
@interface YNTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *duiwu1;
@property (weak, nonatomic) IBOutlet UILabel *duiwu2;
@property (weak, nonatomic) IBOutlet UILabel *winner;
@property (weak, nonatomic) IBOutlet UITextField *defen1;
@property (weak, nonatomic) IBOutlet UITextField *defen2;
@end
@implementation YNTableViewCell
- (void)setTg:(XMGTg *)tg
{
_tg=tg;
self.duiwu1.text = tg.duiwu1;
self.duiwu2.text = tg.duiwu2;
self.defen1.text = [NSString stringWithFormat:@"%@",tg.defen1];
self.defen2.text = [NSString stringWithFormat:@"%@",tg.defen2];
NSInteger a=[self.defen1.text intValue];
NSInteger b=[self.defen2.text intValue];
if (a==b) {
[email protected]"平局";
}else if (b>a)
{
self.winner.text=tg.duiwu2;
}else
{
self.winner.text=tg.duiwu1;
}
}
- (IBAction)fenshu1:(UITextField *)sender {
}
- (IBAction)fenshu2:(UITextField *)sender {
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
结束。
以上是关于标题要长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长的主要内容,如果未能解决你的问题,请参考以下文章