[英]UITableView crashes on scrolling
UITableView在滾動時崩潰。 這是示例代碼。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"Total Count: %d",count);
return [ObjectArray count] ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12.0];
cell.detailTextLabel.font = [UIFont fontWithName:@"Arial" size:10.0];
[cell.textLabel sizeToFit];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
}
// Configure the cell.
NSLog(@"Row Number %d", indexPath.row);
cell.textLabel.text = [ObjectArray name];
return cell;
}
在控制台中,我可以看到總數= 22。
Row Number 0
Row NUmber 1
.
.
Row Number 21 (This row number will pull the last object from ObjectArray)
現在,如果我嘗試滾動,它會崩潰...為什么? 誰能幫我這個 ...
我不太明白這行代碼
cell.textLabel.text = [ObjectArray name];
如果ObjectArray是NSArray實例,則它將不會響應該選擇器。 無論如何,您可能想返回
cell.textLabel.text = [ObjectArray objectAtIndex: [indexPath row]];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.