Skip to content

Instantly share code, notes, and snippets.

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: "")!)
let closeAction = UIPreviewAction(title: "Copy URL", style: .Default) { (action, viewCntrlr) -> Void in
UIPasteboard.generalPasteboard().string = ""
let action1 = UIPreviewAction(title: "Action1", style: .Default) { (action, vc) -> Void in
let action2 = UIPreviewAction(title: "Action2", style: .Default) { (action, vc) -> Void in
let action3 = UIPreviewAction(title: "Action3", style: .Default) { (action, vc) -> Void in
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