问题描述:

I'm having a hard time with a UIViewController...

I have this UINavigationController whose root view controller contains a UITableView which pushes a UIViewController open cell selection.

Sample code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

MySecondViewController *controller = [[MySecondViewController alloc] initWithNibName:@"MySecondViewController" bundle:nil];

[self.navigationController pushViewController:controller animated:YES];

[tableView deselectRowAtIndexPath:indexPath animated:YES];

}

Except it doesn't work as expected!

When pushing, it does the animation alright, but instead of my UIViewController there is nothing but a black screen.

The weird thing is that I can present it modally without problem.

I can also push other UIViewControllers without problem!

I looked for other post about such a problem but couldn't find any.

Others seem to have forgotten something like linking their xib or setting the rootViewController or things like that.

Any hints would be greatly appreciated.

网友答案:

Heads up guys, I figured it out!

Turns out, it is a 3rd party lib I was using that caused the problem.
It just got updated and apparently isn't compatible with my implementation.
I still don't know why it failed like that but reverting to a previous version did the trick.
I was initializing it in the viewDidLoadof MySecondViewController.

Thanks for the hints.

网友答案:

Try this. Problem : Wrong VC pushed

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    MySecondViewController *controller = [[MySecondViewController alloc] initWithNibName:@"MySecondViewController" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];
}
相关阅读:
Top