UINavigationController不推送viewcontrollers

时间:2016-03-07 09:08:43

标签: iphone uitableview didselectrowatindexpath

我正在创建一个表格视图应用程序。 当触摸表格视图中的单元格时,我必须显示Web视图。 但是tableView的导航控制器显示的是零值。 并没有推动detailViewController。 任何人都可以帮我解决这个问题。

- (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);
    }

NavigationController Value in debugger

1 个答案:

答案 0 :(得分:0)

我想问题是创建你的控制器这行

character = getchar();
while ((numberOfRead < 40) && (character != EOF) && (character != '\n')) {
    numberOfChars++;
    ...
    character = getchar();
}

尝试用这个替换它

NewsDetailsViewController *detailsVc=[[NewsDetailsViewController alloc]initWithNibName:@"NewsDetailsViewController" bundle:nil];

无论如何,我建议你转向使用Storyboards和Segues