236

crash on showing UIPopOverPresentationController

Question:

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

Answer1:

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)

Answer2:

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) }

Recommend

  • UIActivityViewController Size
  • UIActivityViewController reports “Remote compose controller timed out”
  • Embedded h2 database: getting connection but table not found
  • Where and How To Define An Application Property? - JHIpster
  • Response of a GraphQL query/mutation
  • How to Navigate from Initial UIViewController to UISplitViewController in Swift
  • Error authenticating using LinkedIn iOS SDK
  • Eclipse code fomatting
  • sqlite3_wal_checkpoint_v2 always returns SQL_BUSY
  • How to read files recursively in Java 7?
  • Thread Synchronization with IntentService
  • getting image type of remote image in php
  • Detaching entity along with referenced entities
  • iPhone - UIWebView multiple locks
  • substitute period from abbreviation (single letter + period) unless followed by a capital letter
  • Spring Integration debounce/deduplicate
  • Powerpoint 2010 VSTO AddIn taskpane on multiple Windows
  • Why does this empty dict break shared references?
  • Keep transition effect on 1 div from moving the div that follows?
  • Updating one element of a bound Observable collection
  • “A GKScore must specify a leaderboard.”
  • How to protect an asp:textbox from user input?
  • c++ using primitive types as a base class
  • Android Lock Screen C# .NET Replica
  • Cannot invoke my method on the array type int[]
  • runtime error when linking ffmpeg libraries in qt creator
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • MongoDb aggregation
  • Is there a way to do normal logging with EureakLog?
  • How to set my toolbar fixed while scrolling android
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • apache spark aggregate function using min value
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?