analogcode / Swift-Radio-Pro

Professional Radio Station App for iOS!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slight fix for the Share button

RobertChalmers opened this issue · comments

The Share button wasn't working - crashed on the iPad. A little fix for that here. Others may wish to modify if needed.
` @IBAction func shareButtonPressed(_ sender: UIButton) {
let songToShare = "I'm listening to (currentTrack.title) on (currentStation.name) via Swift Radio Pro"
let activityViewController = UIActivityViewController(activityItems: [songToShare, currentTrack.artworkImage!], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

    // exclude some activity types from the list (optional)
    //activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]
    
    // present the view controller
    self.present(activityViewController, animated: true, completion: nil)

  /*
    activityViewController.completionWithItemsHandler = {(activityType: UIActivityType?, completed:Bool, returnedItems:[Any]?, error: Error?) in
        if completed {
            // do something on completion if you want
        }
    }
    present(activityViewController, animated: true, completion: nil)
     */
}`

@ShanghaiTimes Thanks,

The app UI for now supports only the iPhone, I will fix the part that causing the crash in case someone wants to use the same UI for the iPad.