我有这样的视图控制器的结构为:UINavigationController(root view controller)->UIViewController
。在我的UIViewController
我有UITableView
动态细胞。在每个单元格中都有“共享”按钮,其呈现全屏UIWindow
。这个UIWindow
包含一个UIView
社交网络按钮,每个按钮都必须显示共享对话框,一切都正常,只适用于社交网络框架或库的按钮,但我有一个按钮,必须提供自定义共享对话框。当我按下它我的应用程序有以下错误而崩溃:*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'adding a root view controller <REComposeViewController: 0x7f9e8b416260> as a child of view controller:<AVMNavCon: 0x7f9e887540f0>'
当呈现视图控制器时UIViewControllerHierarchyInconsistency
这就是我试图表明我的对话:
-(void)shareWithLinkedIn:(AVMSocNetButton*)sender{
[self closeWhiteView]; // close UIWindow with social network buttons
REComposeViewController *composeViewController = [[REComposeViewController alloc] init]; // define and initialize custom share dialog
composeViewController.title = @"Social";
composeViewController.hasAttachment = YES;
composeViewController.attachmentImage = sender.shareImage;
composeViewController.text = [NSString stringWithFormat:@"Share text"];
testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 74, SCREEN_WIDTH-10, SCREEN_HEIGHT/2)];
testWindow.windowLevel = UIWindowLevelStatusBar;
testWindow.hidden = NO;
testWindow.rootViewController = composeViewController;
[composeViewController presentFromRootViewController];
[self performSelector:@selector(showShareWindow) withObject:nil afterDelay:1];
}
正如每个人都可以在这里看到我用另外一个UIWindow
(testWindow)。这是因为如果我将显示我的对话框没有UIWindow
我的UIViewController
将消失,我会看到黑色背景上的共享对话框。 然后,如果我评论行testWindow.rootViewController = composeViewController;
我会看到我的共享对话框,但没有任何交互(我无法触摸屏幕上的任何按钮) 我应该如何展示我的对话框并避免此错误?
编辑:
完整层次是:UINavigationController
- >UIViewController
- >UITableView
- >UITableViewCell
- >UIButton
- >(呼叫 “WhiteView” UIWindow
) - >UIWindow
- >UIButton
- >(调用shareWithLinkedIn
方法)
'showShareWindow'的作用是什么?和'closeWhiteView'实际上关闭了testWindow? – gabbler 2015-02-12 12:12:55
@gabbler'showShareWindow'确实调用' - (void)shareWithLinkedIn:(AVMSocNetButton *)sender'方法调用'[testWindow makeKeyAndVisible]'和'closeWhiteView'关闭'UIWindow'。请参阅我的编辑以获得解释 – vendettacore 2015-02-12 12:21:09
您是如何关闭WhiteView并关闭窗口的? – gabbler 2015-02-12 12:32:11