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
Post a Comment