在故事板中,我有一个视图控制器,如果其他应用尝试使用我的应用"open in"
,则会显示pdf文件。
在模拟器IOS 5.1或IOS 6 +中,它运行良好但在设备上我在主线程上得到SIGABRT
并出现此错误:
[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
奇怪的是我在相关的viewcontrollers中没有任何UIPopoverController
。
在find中搜索“UIPopoverController”并且没有任何相关控制器(offlinereader,leftSideMenuViewController,navigationController)都有一个popovercontroller
#pragma OpeIn
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
// Make sure url indicates a file (as opposed to, e.g., http://)
if (url != nil && [url isFileURL]) {
NSLog(@"Url in app delegate= %@",url);
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
OfflineReaderViewController *registerVC = [sb instantiateViewControllerWithIdentifier:@"OfflineReaderViewController"];
// Override point for customization after application launch.
registerVC.filePath=url;
self.viewController = registerVC;
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:self.viewController animated:YES completion:NULL];
// Tell our OfflineReaderViewController to process the URL
[self.viewController handleDocumentOpenURL:url];
}
// Indicate that we have successfully opened the URL
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
UITabBarController *navigationController = (UITabBarController *)self.window.rootViewController;
UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
[MFSideMenu menuWithNavigationController:navigationController
leftSideMenuController:leftSideMenuViewController
rightSideMenuController:nil];
return YES;
}
offlinereader是: UIViewController<UIDocumentInteractionControllerDelegate>
怎么回事? 我该如何解决或找到确切的问题?
修改:::: 完整错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
*** First throw call stack:
(0x317932a3 0x3962997f 0x317931c5 0x33986d5f 0x338d7285 0x338d7b35 0xe49cf 0xe51a5 0x335ba595 0x33603fd7 0x33603f45 0x336884ef 0x33686fe7 0x51bb3 0x3376bb33 0x33744881 0x33743f6b 0x3359bd59 0x3359b6cd 0x3359b11b 0x3528f5a3 0x31768683 0x31767ee9 0x31766cb7 0x316d9ebd 0x316d9d49 0x3528e2eb 0x335ef301 0x50c89 0x50c10)
libc++abi.dylib: terminate called throwing an exception
答案 0 :(得分:0)
SIGABRT
错误对本教程有帮助,并找出问题的确切行。
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
当您发现问题时,必须在断点行
中确定一些popover代码如果有,请添加此
if (self.view.window != nil) {
//your popover code
}
上面的代码基本上只检查是否存在窗口,然后运行代码。