swift - What is the right code for the UIPopoverController -


what right code popovercontroller in ios 9 have anywhere right code code?


@ibaction func share(sender: uibarbuttonitem) {

    let activityviewcontroller = uiactivityviewcontroller (         activityitems: [(webview.request?.url!.absolutestring)! nsstring],         applicationactivities: nil)      if uidevice.currentdevice().userinterfaceidiom == .pad {         //ipad          let activitypopover = uipopovercontroller(contentviewcontroller: activityviewcontroller)         activitypopover.presentpopoverfrombarbuttonitem(self.sharebutton, permittedarrowdirections: uipopoverarrowdirection.any, animated: true)     }     else     {         //iphone         presentviewcontroller(activityviewcontroller, animated: true, completion: nil)      } } 

}

your code ancient. should throw of away. in ios 8 , ios 9, presented controllers adapt. uiactivityviewcontroller popover on ipad, automatically. present , right thing happen.

of course, have supply sourceview , sourcerect or bar button item source. otherwise, you'll crash on ipad. that's case any popover, can't surprised it.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -