Skip to content

iPad 上使用AXWebViewController 点击 actionBarButtonItem 按钮必崩溃。iOS 11 #63

@iodefog

Description

@iodefog

原因是ipad上缺少 UIPopoverPresentationController

建议改成这样

  • (void)actionButtonClicked:(id)sender {
    NSArray *activities = @[[NSClassFromString(@"AXWebViewControllerActivitySafari") new], [NSClassFromString(@"AXWebViewControllerActivityChrome") new]];
    NSURL *URL;
    #if AX_WEB_VIEW_CONTROLLER_USING_WEBKIT
    URL = _webView.URL;
    #else
    URL = _webView.request.URL;
    #endif

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:activities];

    UIPopoverPresentationController *popover = activityController.popoverPresentationController;
    if (popover) {
    popover.sourceView = self.view;
    popover.sourceRect = CGRectMake(CGRectGetWidth(self.view.bounds)-400, 0, 200, 200);
    popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
    }

    [self presentViewController:activityController animated:YES completion:nil];
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions