Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implementation Preview Actions for 3D touch
override func previewActionItems() -> [UIPreviewActionItem] {
let safariAction = UIPreviewAction(title: "Open with Safari", style: UIPreviewActionStyle.Default) { (action, viewCntrlr) -> Void in
UIApplication.sharedApplication().openURL(NSURL(string: "http://y8k.me")!)
}
let closeAction = UIPreviewAction(title: "Copy URL", style: .Default) { (action, viewCntrlr) -> Void in
UIPasteboard.generalPasteboard().string = "http://y8k.me"
}
let action1 = UIPreviewAction(title: "Action1", style: .Default) { (action, vc) -> Void in
print("action1")
}
let action2 = UIPreviewAction(title: "Action2", style: .Default) { (action, vc) -> Void in
print("action2")
}
let action3 = UIPreviewAction(title: "Action3", style: .Default) { (action, vc) -> Void in
print("action3")
}
let actionGroup = UIPreviewActionGroup(title: "Actions", style: UIPreviewActionStyle.Default, actions: [action1, action2, action3])
return [safariAction, closeAction, actionGroup]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment