【发布时间】:2015-10-20 23:56:53
【问题描述】:
我有多个自定义单元格。我将其中两个子类化。我想用故事板显示具有不同标识符的不同单元格。到目前为止,使用数组我能够显示一个子类单元格,但我遇到了行数和显示多个单元格的技术的问题。我正在使用延迟来继续添加和更新我的表格。
NSMutableArray *conv1;
NSString *l1;
NSString *l2;
NSString *l3;
NSMutableArray *allDialogue;
NSMutableArray *conv2;
}
@end
@implementation PlotController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
conv1 = [[NSMutableArray alloc] init];
conv2 = [[NSMutableArray alloc] init];
allDialogue = [[NSMutableArray alloc] init];
[allDialogue addObjectsFromArray:conv1];
[allDialogue addObjectsFromArray:conv2];
l1 = @"converstaion1";
l2 = @"converstaion2";
l3 = @"converstaion3";
_tableV.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
[self performSelector:@selector(delay) withObject:nil afterDelay:2.0];
[self performSelector:@selector(delay2) withObject:nil afterDelay:4.0];
}
表格视图配置
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MainStoryDialogue *dialogueCell = [tableView dequeueReusableCellWithIdentifier:@"PDialogue"];
dialogueCell.textHere.text = [allDialogue objectAtIndex:indexPath.row];
[self.tableV beginUpdates];
[self.tableV endUpdates];
return dialogueCell;
}
第二个问题是行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [allDialogue count];
}
【问题讨论】:
-
像我说的那样添加多个自定义单元格
-
顺便说一句,
cellForRowAtIndexPath表视图控制器生命周期方法中的开始和结束更新调用什么都不做。
标签: objective-c uitableview row cell