3
votes

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.

2
Did you check you XIB name "MySecondViewController" ? Is it the exact one ? - βhargavḯ
You are pushing controller or programVC? - NightFury
The UInavigation Controller may cause this issue . Check properly with the UInavigationController . - Kumar KL
you are pushing "programVC" instead of "controller". - Nookaraju
@Bhargavi Yes, I checked my xib, and since it is showing when presented modally I don't think the xib is to blame. And since I can push other view controllers without having the problem I don't see how the navigation controller is to blame. It is a really weird behavior! As for the rest of your hints, sorry guys, I just forgot to change the name of the variable in the sample code I provided. Sure enough I didn't call my controller 'MySecondViewController'. - yonicsurny

2 Answers

1
votes

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.

0
votes

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];
}