gpt4 book ai didi

xcode - iOS5 iPad UIPopoverController initWithContentViewController NSGenericException

转载 作者:行者123 更新时间:2023-12-03 05:10:33 25 4
gpt4 key购买 nike

以下代码:

listViewPopoverControllerOL = [[UIPopoverController alloc] initWithContentViewController:myBranchesListViewPage];

在装有 iOS5 的 iPad2 中产生以下崩溃。作为评论,我必须注意到相同的代码在 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

其中“myBranchesListViewPage”定义为:

MyBranchesListView_iPad* myBranchesListViewPage

并且“MyBranchesListViewPage”定义为:

MyBranchesListView_iPad : UIViewController<UITableViewDelegate, UITableViewDataSource, MyDetailParserDelegate, UISplitViewControllerDelegate>

我不知道为什么在 iOS5 (Xcode 4.2) 中出现此问题,但在 iOS4.3 (Xcode 4.1) 中却没有出现此问题

提前致谢

最佳答案

我也遇到了同样的问题。就我而言,我正在执行以下操作:

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

为了解决这个问题,我只是将 navigationController 传递给 UIPopoverController 而不是 popupController 来初始化:

UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:navigationController];

根本不向 popupController 添加导航 Controller 也可以修复该问题,但显然弹出窗口中没有导航 Controller 。

MyViewController * popupController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[popupController setDelegate:self];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:popupController];
[popupController release];

关于xcode - iOS5 iPad UIPopoverController initWithContentViewController NSGenericException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7766051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com