如何在UItabViewController 使用自定义UitabViewCell

qq_25551149 2016-04-21 04:44:00
在UitableViewController 用自定义的UItableViewCell 初始化,他怎么都不走- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 这个方法



@interface CustomTableViewController ()
@property (nonatomic , strong)LeftTableViewCell *leftCell;
@end

@implementation CustomTableViewController

- (instancetype)initWithCustomCell:(NSString *)customCellName imageArray:(NSMutableArray *)imageArray textArray:(NSMutableArray *)textArray textDetailArray:(NSMutableArray *)detailArray {
self = [super init];
if (self) {
customCellName = _Customcell;
if (_Imagearray) {
imageArray = _Imagearray;
}
if (_textArray) {
textArray = _textArray;
}
if (_textDetailArray) {
detailArray = _textDetailArray;
}
}
self.tableView.rowHeight = 80;

return self;
}

- (void)viewDidLoad {
[super viewDidLoad];

[self.tableView registerClass:[LeftTableViewCell class] forCellReuseIdentifier:@"customCell"];
self.tableView.delegate = self;
self.tableView.dataSource = self;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];

}

#pragma mark - Table view data source



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

return _textArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Class TableCell = NSClassFromString(_Customcell);
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
if (!cell) {
cell = _leftCell;
}
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
[_leftCell setcell:_Imagearray[indexPath.row] titleString:@"hhhhhhhh"];

// cell.imageView.image = [UIImage imageNamed:_Imagearray[indexPath.row]];
// cell.backgroundColor = [UIColor whiteColor];

return cell;
}
...全文
71 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,115

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧