Ios UITableView未呈现所有部分
我有一个UIViewController,里面有一个UITableView。UITableView有3个部分,如下所示Ios UITableView未呈现所有部分,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个UIViewController,里面有一个UITableView。UITableView有3个部分,如下所示 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } 我的细胞是这样设置的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
我的细胞是这样设置的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ContactInfoCellIdentifier";
NSUInteger section = [indexPath section];
UITableViewCell *cell;
switch (section)
{
case 0:
{
...
break;
}
case 1:
{
...
break;
}
case 2:
{
...
break;
}
default:
break;
}
return cell;
}
但由于某种原因,案例2第3节从未被调用。你知道为什么会这样吗?你需要像这样实例化UITableViewCell
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:“YourIdentifier”]
对于numberOfRowsInSection
返回什么?它返回数组中的计数,如果数组为空,则返回1,因此每个节应始终至少有1行