4

I'm trying to create QML mobile app with sharing option (mail, Twitter...). Everything works fine on iOS emulator, but when I run app on iPad and press the share button the app stops working.

I'm not sure what is wrong.

Here is a code used for show 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`m getting this error message:

Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x17eba1e0>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'

halfer
  • 19,824
  • 17
  • 99
  • 186
Jarda
  • 81
  • 8
  • Does [this answer](http://stackoverflow.com/a/25644145/2538363) provide a solution to your error? – BaCaRoZzo Jun 03 '15 at 15:17
  • `activityController.popoverPresentationController.sourceView = qtController.view;` this line will do the magic propably;) – Jarda Jun 03 '15 at 15:51
  • 1
    I will test it on different devices and share results...THX for help :-) – Jarda Jun 03 '15 at 15:54
  • It`s working..but when i choose facebook share it sends only URL...without text...Any advice pls? – Jarda Jun 04 '15 at 11:46
  • Can't help. Just search SO, like I did for the original problem, maybe you'll find a solution. – BaCaRoZzo Jun 04 '15 at 16:27

0 Answers0