小编Pho*_*Dev的帖子

UITableView 的单个视图中存在多少个单元格?

在开始使用其 dequeueReusableCellWithIdentifier 委托之前,有人问我一个问题,即表格视图的单个视图中有多少个单元格。

I used the following program but it resets after 12 rows and begins with 1 again.

NSMutableArray *array;

-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell==nil){
    cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];


    NSString *cellValue = [array objectAtIndex:indexPath.row];

    cell.textLabel.text=cellValue;
}

return cell;

}

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
    return [array count];
}
Run Code Online (Sandbox Code Playgroud)

And my viewDidLoad

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.


array = [[NSMutableArray alloc]init]; …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios

2
推荐指数
1
解决办法
1542
查看次数

标签 统计

ios ×1

iphone ×1

uitableview ×1