使用initwithstyle方法初始化UITableViewCell
在初始化UITableViewCell时,有人能解释一下这里发生了什么吗?谢谢使用initwithstyle方法初始化UITableViewCell,uitableview,Uitableview,在初始化UITableViewCell时,有人能解释一下这里发生了什么吗?谢谢 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { NSArray *nibArray=[[
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSArray *nibArray=[[NSBundle mainBundle]loadNibNamed:@"CustomCell" owner:nil options:nil];
self=[nibArray objectAtIndex:0];
}
return self;
}
试试这个
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
if (cell == nil) {
// Load the nib array from the custom cell XIB.
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
// Grab a pointer to the first object
cell = [nibArray objectAtIndex:0];
}
//set cell data
return cell;