【发布时间】:2011-11-10 16:16:50
【问题描述】:
我可以动态获得行数吗? 我正在尝试删除 tableView 部分标题,但我不知道如何......我已经教过一个解决方案是更改部分的数量。
现在我的 numberOfSectionsInTableView 看起来像:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
和
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
beTribesAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
switch (section) {
case 0:
return [appDelegate.firstArray count];
case 1:
return [appDelegate.secondArray count];
default:
return 0;
}
}
像这样设置标题部分:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
sectionTitles = [[NSMutableArray alloc] init];
[sectionTitles addObject:@"firstSection"];
[sectionTitles addObject:@"secondSection"];
NSString *sectionText = [sectionTitles objectAtIndex:section];
return sectionText;
}
【问题讨论】:
标签: iphone uitableview ios5 tableview