1

在情节提要中,我有一个视图控制器,如果其他应用程序尝试"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.'

奇怪的是我UIPopoverController在相关的视图控制器中没有任何东西。

在查找中,我搜索“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;

    }

离线阅读器是: 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
4

1 回答 1

0

SIGABRT错误很有帮助,请按照本教程找到您的问题所在。

http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1

当您发现问题时,您的断点行中必须有一些明确相关的弹出框代码。

如果是这样添加这个

if (self.view.window != nil) {
    //your popover code
}

上面的代码基本上只是检查是否存在窗口,运行代码。

于 2013-05-01T17:41:23.683 回答