ios - How to dismiss the UIActivityViewController on clicking the Cancel button? -


    let activityvc = uiactivityviewcontroller(activityitems: objectstoshare, applicationactivities: nil)     let excludeactivities = [uiactivitytypeairdrop, uiactivitytypeprint, uiactivitytypeassigntocontact, uiactivitytypesavetocameraroll, uiactivitytypeaddtoreadinglist, uiactivitytypeposttoflickr, uiactivitytypeposttovimeo,uiactivitytypemail,uiactivitytypeopeninibooks,uiactivitytypecopytopasteboard]      activityvc.excludedactivitytypes=excludeactivities     let nav = uinavigationcontroller(rootviewcontroller: activityvc)     nav.modalpresentationstyle = uimodalpresentationstyle.popover     let popover = nav.popoverpresentationcontroller uipopoverpresentationcontroller!     activityvc.preferredcontentsize = cgsizemake(0,150)     popover.sourceview = self.view     popover.sourcerect = cgrectmake(345,580,0,0)     self.presentviewcontroller(nav, animated: true, completion: nil) 

i'm trying dismiss activity controller when cancel button clicked not working. on clicking anywhere outside controller,this gets dismissed not tapping cancel button.

just use

 let text = string(format:"download app on iphone")                          // set activity view controller                         let objectstoshare: [anyobject] = [ text ]                          self.activityviewcontroller = uiactivityviewcontroller(activityitems: objectstoshare, applicationactivities: nil)                         self.activityviewcontroller.popoverpresentationcontroller?.sourceview = self.view // ipads won't crash                         self.activityviewcontroller.completionwithitemshandler = { activity, success, items, error in                             if success {                                 // success handling here                                                             }                          }                         // exclude activity types list (optional)                         self.activityviewcontroller.excludedactivitytypes = [ uiactivitytypeairdrop, uiactivitytypeposttofacebook ]                          // present view controller                         self.presentviewcontroller(self.activityviewcontroller, animated: true, completion: nil) 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -