[英]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.