12

I am trying to figure out how to create a user interactive post or tweet kind of like SoundCloud's here below:

(Shared directly from Sound Cloud)

The portion highlighted in yellow is the part that interests me because as far as I can tell when it comes to UIActivityViewController (which is what Sound Cloud uses for this) the only objects that work for sharing are images and strings.

Further more, if you were to tap the portion highlighted in yellow this screen would pop up on twitter:

enter image description here

HOW DO THEY DO THAT!? THEY HAVE A PAUSE BUTTON AND EVERYTHING!

This is my attempt to do that...

func displayShareSheet(shareContent:String) {

        let someView:CustomView = CustomView() // CustomView is a subclass of UIView

        let activityViewController = UIActivityViewController(activityItems: [someView], applicationActivities: nil)
        presentViewController(activityViewController, animated: true, completion: {})
    }

...which doesn't work. The UIActivityViewController sheet pops up with no share options indicated.

I understand that some may consider this a broad question but if you could at least point me in the right direction I would be very grateful. Thank You.

Garret Kaye
  • 2,412
  • 4
  • 21
  • 45
  • Your gigantic images make your question hard to read, I suggest you shrink the image size so question would be appealing and you'd get more attention – mfaani Aug 19 '16 at 18:56

2 Answers2

2

This works. For the full list of sharing destinations run it on your device and not the simulator. The simulator gives you a smaller list.

func createActivityController() -> UIActivityViewController {
    let someText:String = textView.text

    let google = NSURL(string:"http://google.com/")!

    // let's add a String and an NSURL
    var activityViewController = UIActivityViewController(
        activityItems: [someText, google],
        applicationActivities: nil)

    activityViewController.completionHandler = {(activityType, completed:Bool) in
        if !completed {
            print("cancelled")
            return
        }

        if activityType == UIActivityTypePostToTwitter {
            print("twitter")
        }

        if activityType == UIActivityTypeMail {
            print("mail")
        }
    }

    // you can specify these if you'd like.
    //        activityViewController.excludedActivityTypes =  [
    //            UIActivityTypePostToTwitter,
    //            UIActivityTypePostToFacebook,
    //            UIActivityTypePostToWeibo,
    //            UIActivityTypeMessage,
    //            UIActivityTypeMail,
    //            UIActivityTypePrint,
    //            UIActivityTypeCopyToPasteboard,
    //            UIActivityTypeAssignToContact,
    //            UIActivityTypeSaveToCameraRoll,
    //            UIActivityTypeAddToReadingList,
    //            UIActivityTypePostToFlickr,
    //            UIActivityTypePostToVimeo,
    //            UIActivityTypePostToTencentWeibo
    //        ]

    return activityViewController
}
Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36
2

For the first part it's only play button that clicks you to popup the player view.

Second: You can do this by just popping a new viewController, use any popup pod: CWPOP as ex. Or whatever suits you or as Twitter here i'm not sure but probably they're doing their own, and you just build a normal view which has the play and everything.

They used do it better before and let you play the music during going through tweets, that was way better to me at least.

Abdoelrhman
  • 906
  • 8
  • 17
  • Thank you for your response but do you know how I actually pass say a view controller with UIActivityViewController? – Garret Kaye Aug 22 '16 at 16:36