Customize content in Share using Swift -


i trying make share button game. know, ones when click popup menu comes options. wondering how make different options different things. wondering how make "save camera roll" option. ill post code below.

@ibaction func share(sender: uibutton) {      let firstactivity = "yes! scored \(scorenumber) in dotcha! #dotcha @snowcapps_dev https://itunes.apple.com/us/app/dotcha!/id977870313?ls=1&mt=8"       let activityviewcontroller : uiactivityviewcontroller = uiactivityviewcontroller(activityitems: [firstactivity], applicationactivities: il)             self.presentviewcontroller(activityviewcontroller, animated: true, completion: nil)         } 

if want customize text twitter, facebook, mail, etc, can inherit class uiactivityitemprovider in following way :

class customprovider : uiactivityitemprovider {     var facebookmessage : string!    var twittermessage : string!    var emailmessage : string!     init(placeholderitem: anyobject, facebookmessage : string, twittermessage : string, emailmessage : string) {       super.init(placeholderitem: placeholderitem)       self.facebookmessage = facebookmessage       self.twittermessage = twittermessage       self.emailmessage = emailmessage    }     override func item() -> anyobject! {        switch (self.activitytype!) {       case uiactivitytypeposttofacebook:           return self.facebookmessage       case uiactivitytypeposttotwitter:           return self.twittermessage       case uiactivitytypemail:           return self.emailmessage       default:           return "any message"       }            } } 

and can call uiactivityviewcontroller in following way example:

let firstactivityitem = customprovider(placeholderitem: "default", facebookmessage: "facebook", twittermessage: "twitter", emailmessage: "mail") let secondactivityitem : nsurl = nsurl(string: "http://www.google.com")! let image : uiimage = uiimage(named: "nameofyourimage.ext")!  let activityviewcontroller : uiactivityviewcontroller = uiactivityviewcontroller(         activityitems: [firstactivityitem, secondactivityitem, image], applicationactivities: nil)      self.presentviewcontroller(activityviewcontroller, animated: true, completion: nil) 

in customprovider class set facebook, twitter , mail can put more if want, it's you.

i hope you.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -