Skip to content

Instantly share code, notes, and snippets.

@y8k
Created October 27, 2015 05:27
Show Gist options
  • Save y8k/b691fb0964a8944cb495 to your computer and use it in GitHub Desktop.
Save y8k/b691fb0964a8944cb495 to your computer and use it in GitHub Desktop.
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