first time, please be gentle...
I've an iOS app; a tabbed RSS reader, each tab has a different navigation view of various RSS feeds. All is well, until you select the row to view the feed, when nothing happens. Code I'm using is:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_webViewController == nil) {
self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bu开发者_StackOverflow中文版ndle:[NSBundle mainBundle]] autorelease];
}
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
_webViewController.entry = entry;
[self.navigationController pushViewController:_webViewController animated:YES];
}
Where RSSEntry is a class which just sets the variables for the RSS feed. I've set up a WebViewController.xib, m and h to hold the view.
When you select the row, nothing happens. Any ideas gratefully accepted.
thanks
Rob
Does self.navigationController evaluate to non-nil? In some cases the property navigationController may not point to your enclosing UINavigationController. I've seen this with special view controller hierarchies...
_webViewController
has likely been released when you go to use it, because you've allocated it within the if
block. At the end of that block, it is autoreleased.
Remove the autorelease
clause in your alloc statement for WebViewController, and add [webViewController release]
after your call to pushViewController.
精彩评论