iOS:无法导航到另一个视图控制器

时间:2013-06-12 07:41:11

标签: ios uitableview

我有一个主视图控制器,我有一个UITableView。在didSelectRowAtIndexPath()中,我正在初始化一个新的视图控制器并尝试导航到它。以下是我的代码。但我无法转到其他视图控制器。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SubViewController *subView = [[SubViewController alloc] init];
    [subView setData:[[sources getSubCategories] objectAtIndex:[indexPath row]]];
    [[self navigationController]pushViewController:subView animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

1 个答案:

答案 0 :(得分:0)

尝试这个添加通过initwith Nibname ...

SubViewController *subView = [[SubViewController alloc]initWithNibName:@"SubViewController" bundle:Nil];

    // Puishing a view controller in naviogation bar.
    [self.navigationController pushViewController:subView animated:YES];

试试这个可能对你有所帮助......