Why won't my UITableViewCell deselect and update its text?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2011-01-04T16:44:18Z Indexed on 2011/01/04 16:53 UTC
Read the original article Hit count: 153

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];
}
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c