I'm new to Swift and trying to figure out how it works. I'm having a problem with the Alert Sheet. On iPhone 5S is working fine (it opens the Sheet and then the Facebook and Twitter alert) but I'm getting the error: "LaunchServices: invalidationHandler called".
On an iPad Air 2, with the code I have, the alert opens but its position (and the arrow) is not next to the shareACtion button, but actually on the opposite side of the screen. Besides, it's not doing any action.
I've imported the Social framework and the UIActionSheetDelegate.
Thanx
@IBAction func shareAction(sender: AnyObject) {
let actionSheet = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: "OK", destructiveButtonTitle: nil,otherButtonTitles: "Twitter", "Facebook")
actionSheet.showInView(self.view)
}
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int)
{
switch buttonIndex{
case 1:
SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter)
var tweetSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
tweetSheet.setInitialText("I'm using the app Test")
tweetSheet.addImage(UIImage(named: "picture1.png"))
self.presentViewController(tweetSheet, animated: true, completion: nil)
break;
case 2:
SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook)
var FBSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
FBSheet.setInitialText("I'm using the app Test")
FBSheet.addImage(UIImage(named: "picture1.png"))
self.presentViewController(FBSheet, animated: true, completion: nil)
break;
default:
break;
}
}
Aucun commentaire:
Enregistrer un commentaire