*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x1a56bd90>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
Asked
Active
Viewed 1,183 times
1
-
Please show the code where you are presenting the popover controller. – JAL Nov 25 '15 at 15:02
-
is it because of I am running in iPad Simulator? – Pravin S. Nov 26 '15 at 05:47
-
Possible duplicate of [ActionSheet not working iPad](https://stackoverflow.com/questions/28089898/actionsheet-not-working-ipad) – Tieme Jul 04 '19 at 09:32
2 Answers
0
self.dismissViewControllerAnimated(true, completion: nil)
let textToShare:String = "Lets have a chat!";
let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [textToShare], applicationActivities: nil)
let excludeActivities = [UIActivityTypeAirDrop, UIActivityTypePrint, UIActivityTypeSaveToCameraRoll, UIActivityTypeAssignToContact, UIActivityTypePostToFlickr, UIActivityTypePostToTencentWeibo, UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo]
activityVC.excludedActivityTypes = excludeActivities
activityVC.modalPresentationStyle = UIModalPresentationStyle.FormSheet
presentViewController(activityVC, animated: true, completion: nil)

Pravin S.
- 465
- 7
- 22
0
I modified with below code and found solution.
if (DeviceType.IS_IPAD == false)
{
presentViewController(activityVC, animated: true, completion: nil)
}else {
// Change Rect to position Popover
let popUp = UIPopoverController(contentViewController: activityVC)
popUp.presentPopoverFromRect(CGRectZero, inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
}

Pravin S.
- 465
- 7
- 22