码迷,mamicode.com
首页 > 其他好文 > 详细

标题要长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长

时间:2016-12-24 07:33:33      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:int   nbsp   iba   数据源   dex   pat   form   conf   select   

 

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) {
        self.winner.text=@"平局";
       
    }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

 

 

结束。

标题要长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长

标签:int   nbsp   iba   数据源   dex   pat   form   conf   select   

原文地址:http://www.cnblogs.com/zsj233/p/6216564.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!