The following code:
listViewPopoverControllerOL = [[UIPopoverController alloc] initWithContentViewController:myBranchesListViewPage];
produces the following crash in iPad2 with iOS5. As a comment I have to notice that the same code works perfectly in iOS4.3.
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'The content view controller argument must be the root of its associated view controller hierarchy.'
*** First throw call stack:(0x370cb8bf 0x35eaa1e5 0x370cb7b9 0x370cb7db 0x306f378d 0x306f0db9 0x5692d 0x567d1 0x37025435 0x303499eb 0x303499a7 0x30349985 0x303496f5 0x3034a02d 0x3034850f 0x30347f01 0x3032e4ed 0x3032dd2d 0x35bdfe13 0x3709f553 0x3709f4f5 0x3709e343 0x370214dd 0x370213a5 0x35bdefed 0x3035c743 0x2871 0x2830) terminate called throwing an exception
Where "myBranchesListViewPage" is defined as:
MyBranchesListView_iPad* myBranchesListViewPage
and "MyBranchesListViewPage" is defined as:
MyBranchesListView_iPad : UIViewController<UITableViewDelegate, UITableViewDataSource, MyDetailParserDelegate, UISplitViewControllerDelegate>
I have no idea why I have this problem in iOS5 (Xcode 4.2) but not with iOS4.3 (Xcode 4.1)
Thanks in advance
I had this same issue. In my case I was doing the following:
MyViewController * popupController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[popupController setDelegate:self];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:popupController];
[navigationController setNavigationBarHidden:YES animated:NO ];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:popupController];
[popupController release];
[navigationController release];
To solve this, I just changed to pass in the navigationController to init on UIPopoverController instead of the popupController:
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:navigationController];
Not adding a navigation controller to the popupController at all also fixed it, but then you obviously don't have a navigation controller in the popup.
MyViewController * popupController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[popupController setDelegate:self];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:popupController];
[popupController release];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With