Why won't my UITableViewCell deselect and update its text?
- by Josh
I have a UITableView with a list of stories and a cell at the bottom that loads more stories. I am trying to make the "More Stories..." cell deselect and change its text to "Loading..." when clicked. I have searched all over the internet and all over stackoverflow and I cant figure out why my code isnt working right. Right now, when the "More Stories..." cell is clicked, it stays selected and doesnt ever change its text.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
if (storyIndex == [stories count]) {
UITableViewCell *moreCell = [tableView dequeueReusableCellWithIdentifier:@"more"];
if (moreCell == nil) {
moreCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"more"] autorelease];
} // Set up the cell
moreCell.textLabel.text = @"Loading...";
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self moreStories];
} else {
NSLog(@"%@",[[stories objectAtIndex: storyIndex] objectForKey: @"link"]);
webViewController *webController;
webController = [[webViewController alloc] initWithURLPassed:[[stories objectAtIndex: storyIndex] objectForKey: @"link"]];
[self.navigationController pushViewController:webController animated:YES];
[webController release];
webController =nil;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
}
}