您的位置:首页 > 其它

利用storyboard 自定义cell

2015-11-02 16:06 218 查看
现在讲究的是快速开发,storyboa'r'd自定义cell还是比较少用得,但是开发起来特别快。镔哥就不多说了,直接给你们demo看吧

1:自定义cell

// xdxTableViewCell.h

// 短线狙击

//

// Created by taogu on 15/10/28.

// Copyright © 2015年 com.taogucn.www. All rights reserved.

//

#import <UIKit/UIKit.h>

@interface xdxTableViewCell :
UITableViewCell

@property (strong,
nonatomic) IBOutlet
UILabel *xdxTitle;

@property (strong,
nonatomic) IBOutlet
UIImageView *isBuy;

@property (strong,
nonatomic) IBOutlet
UILabel *xdxName;

@property (strong,
nonatomic) IBOutlet
UILabel *xdxDate;

@end

//

// xdxTableViewCell.m

// 短线狙击

//

// Created by taogu on 15/10/28.

// Copyright © 2015年 com.taogucn.www. All rights reserved.

//

#import "xdxTableViewCell.h"

@implementation xdxTableViewCell

- (void)awakeFromNib {

// Initialization code

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

[super setSelected:selected
animated:animated];

// Configure the view for the selected state

}

@end

主要文件应用:

//

// ViewController.h

// 短线狙击

//

// Created by taogu on 15/10/28.

// Copyright © 2015年 com.taogucn.www. All rights reserved.

//

#import <UIKit/UIKit.h>

@interface ViewController :
UIViewController

@property (strong,
nonatomic) IBOutlet
UITableView *xdxTableView;

@end

//

// ViewController.m

// 短线狙击

//

// Created by taogu on 15/10/28.

// Copyright © 2015年 com.taogucn.www. All rights reserved.

//

#import "ViewController.h"

#import "xdxTableViewCell.h"

@interface
ViewController ()<UITableViewDelegate,
UITableViewDataSource>

@end

@implementation ViewController

- (void)viewDidLoad {

[super
viewDidLoad];

self.title =@"新短线狙击";

self.xdxTableView.delegate =
self;

self.xdxTableView.dataSource =
self;

self.xdxTableView.tableFooterView = [[UIView
alloc]
init];

// Do any additional setup after loading the view, typically from a nib.

}

#pragma mark - UITabelViewDatasource

- ( CGFloat )tableView:(
UITableView *)tableView heightForHeaderInSection:(
NSInteger )section

{

return 12.0 ;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return 10;

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

xdxTableViewCell *cell = (xdxTableViewCell *)[tableView
dequeueReusableCellWithIdentifier:@"xdxTableViewCell"];

// if (_dataArray.count) {

// cell.contentLabel.text=[[_dataArray objectAtIndex:indexPath.row] objectForKey:@"title"];

//

// NSDate * date = [NSDate dateWithTimeIntervalSince1970:[[[_dataArray objectAtIndex:indexPath.row] objectForKey:@"addTime"] longLongValue] ];

// NSDateFormatter * formatter = [[NSDateFormatter alloc] init];

// [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];

// NSString * str = [NSString stringWithFormat:@"%@", [formatter stringFromDate:date]];

//

// cell.timeLabel.text =str;

// [_userDefault setObject:str forKey:@"jueduiTime"];

//

// NSString *imageStr =[[_dataArray objectAtIndex:indexPath.row] objectForKey:@"imageUrl"];//图片

// [cell.neicanImageView setImageWithURL:[NSURL URLWithString:imageStr] placeholderImage:[UIImage imageNamed:@"huodong.png"]] ;

//

// }

return cell;

}

到目前为止你或许还有疑问究竟怎么关联起来storybook建立自定义cell呢?


通过这几个步骤就可以成功啦。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: