应用程序崩溃在UIPopoverPresentationController但没有明确的弹出窗口?

nic*_*ona 16 crash popover in-app-purchase ios ios8

我的应用程序(仅限iOS 8)因尝试IAP时崩溃而被拒绝.我在AdHoc版本中尝试了几乎所有购买过程,但无法重现崩溃.查看审核小组附带的崩溃日志,我在最后一个异常回溯中看到了一个非常奇怪的堆栈跟踪.崩溃看起来涉及UIPopoverController,但是我的应用程序虽然是通用的,但不会在任何地方显式或隐式显示弹出窗口.有没有人知道什么可能触发导致此崩溃的活动?什么可能导致我的应用程序在审核小组仅查看时显示popovers?

Last Exception Backtrace:
0   CoreFoundation                0x186d52084 __exceptionPreprocess + 132
1   libobjc.A.dylib               0x1977a40e4 objc_exception_throw + 60
2   UIKit                         0x18bc0aee0 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2464
3   UIKit                         0x18b7d27d8 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1324
4   UIKit                         0x18b7d1310 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 212
5   UIKit                         0x18b557388 _applyBlockToCFArrayCopiedToStack + 356
6   UIKit                         0x18b4c8e4c _afterCACommitHandler + 532
7   CoreFoundation                0x186d0a388 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
8   CoreFoundation                0x186d07314 __CFRunLoopDoObservers + 360
9   CoreFoundation                0x186d076f4 __CFRunLoopRun + 836
10  CoreFoundation                0x186c35664 CFRunLoopRunSpecific + 396
11  GraphicsServices              0x18fd435a4 GSEventRunModal + 168
12  UIKit                         0x18b53a984 UIApplicationMain + 1488
Run Code Online (Sandbox Code Playgroud)

Bad*_*ate 8

不确定它是否与原始问题的原因相同,但我有完全相同的错误,问题是使用带有ActionSheet样式的UIAlertController,它表示它在iPhone上工作正常,但iPad需要设置sourceview - https:// stackoverflow.com/a/24233937/285694

  • 天哪 - 我确实有完全相同的问题。 (2认同)

小智 -1

首先,您应该检查 UIPopoverPresentationController 是否可用。

NSArray *Items = [NSArray arrayWithObjects:emailBody,anImage, nil];

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];

    if ([UIPopoverPresentationController class] != nil) {   
        UIPopoverPresentationController *popover = activityController.popoverPresentationController;
        if (popover)
        {
            popover.sourceView = sender;
            //popover.sourceRect = sender.bounds;
            popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
        }
    }


    [self presentViewController:activityController animated:YES completion:NULL];  
Run Code Online (Sandbox Code Playgroud)