我正在构建一个iphone应用程序,当我运行我的应用程序然后cellForRowAtIndexPath返回方法 时,我有一个包含99条记录的数组indexPath.row从0到7.这是我的代码如下
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[accountParser accounts]count];//it return 99 records
}
- (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];
NSLog(@"Index : %d",indexPath.row);//this print index 0 to 7 only
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
当您显示UITableView时,它只调用tableView:cellForRowAtIndexPath:用于可见行.这意味着只有当您滚动视图时,它才会调用其他行(在您的情况下为8到99).
| 归档时间: |
|
| 查看次数: |
829 次 |
| 最近记录: |