UINavigationController不推送视图控制器
问题描述:
我正在创建一个表视图应用程序。 当表格视图中的单元格被触摸时,我必须显示一个网页视图。 但tableView的导航控制器显示一个零值。 它不会推送到detailsViewController。 任何人都请帮我解决这个问题。UINavigationController不推送视图控制器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NewsDetailsViewController *detailsVc=[[NewsDetailsViewController alloc]initWithNibName:@"NewsDetailsViewController" bundle:nil];
NSString *launchURL = [nf.newsStories [indexPath.row] objectForKey:@"link"];
detailsVc.url = launchURL;
NSLog(@"View controllers before pushing : %@",self.navigationController.viewControllers);
[self.navigationController pushViewController:detailsVc animated:YES];
NSLog(@"View controllers after pushing : %@",self.navigationController.viewControllers);
}
答
我想这个问题是与创建您的控制器,该行
NewsDetailsViewController *detailsVc=[[NewsDetailsViewController alloc]initWithNibName:@"NewsDetailsViewController" bundle:nil];
尝试用这一个
NewsDetailsViewController *detailsVc= [[NSBundle mainBundle] loadNibNamed:@"NewsDetailsViewController"
owner:self
options:nil][0];
来取代它无论如何,我劝你转向使用Storyboard和Segues
NewsViewerController是从someview目前? – Hardik