QML iOS app sharing error: "UIPopoverPresentationController ... must not have a zero sourceView or barButtonItem set before the presentation takes place"

I am trying to create a QML mobile app with the ability to share (mail, Twitter ...). Everything works fine on the iOS emulator, but when I launch the application on the iPad and click the "Share" button, the application stops working.

I'm not sure what is wrong.

Here is the code used to display the sharing options:

NSMutableArray *sharingItems = [NSMutableArray new];
if (!text.isEmpty()) {
    [sharingItems addObject:text.toNSString()];
}
if (url.isValid()) {
    [sharingItems addObject:url.toNSURL()];
}

UIViewController *qtController = [[UIApplication sharedApplication].keyWindow rootViewController];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];

[qtController presentViewController:activityController animated:YES completion:nil];

I get this error message:

- "NSGenericException", : "UIPopoverPresentationController (& lt; _UIAlertControllerActionSheetRegularPresentationController: 0x17eba1e0>) sourceView barButtonItem, , ".

+4

All Articles