UITableView is crashing on scrolling . Here is the sample code..
- (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;
}
In console I can see Total count = 22.
Row Number 0
Row NUmber 1
.
.
Row Number 21 (This row number will pull the last object from ObjectArray)
Now if I try to scroll it crashes...why? Can anyone help me with this ...
I don't really understand this line of code
cell.textLabel.text = [ObjectArray name];
If ObjectArray is a NSArray instance, then it would not respond to that selector. And anyway you probably want to return smth like
cell.textLabel.text = [ObjectArray objectAtIndex: [indexPath row]];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.