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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -