3Dtouch方法

@UIApplicationMain

classAppDelegate:UIResponder,UIApplicationDelegate{

varwindow:UIWindow?

funcapplication(application:UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) ->Bool{

// Override point for customization after application launch.

//添加icon 3d Touch

letfirstItemIcon:UIApplicationShortcutIcon=UIApplicationShortcutIcon(type: .Share)

letfirstItem =UIMutableApplicationShortcutItem(type:"1", localizedTitle:"分享", localizedSubtitle:nil, icon: firstItemIcon, userInfo:nil)

letfirstItemIcon1:UIApplicationShortcutIcon=UIApplicationShortcutIcon(type: .Compose)

letfirstItem1 =UIMutableApplicationShortcutItem(type:"2", localizedTitle:"编辑", localizedSubtitle:nil, icon: firstItemIcon1, userInfo:nil)

application.shortcutItems= [firstItem,firstItem1]

returntrue

}

/**

3D Touch跳转

- parameter application:application

- parameter shortcutItem:item

- parameter completionHandler: handler

*/

funcapplication(application:UIApplication, performActionForShortcutItem shortcutItem:UIApplicationShortcutItem, completionHandler: (Bool) ->Void) {

lethandledShortCutItem =handleShortCutItem(shortcutItem)

completionHandler(handledShortCutItem)

}

funchandleShortCutItem(shortcutItem:UIApplicationShortcutItem) ->Bool{

varhandled =false

ifshortcutItem.type=="1"{//分享

letrootNavigationViewController=window!.rootViewControlleras?UINavigationController

letrootViewController = rootNavigationViewController?.viewControllers.firstasUIViewController?

rootNavigationViewController?.popToRootViewControllerAnimated(false)

rootViewController?.performSegueWithIdentifier("toShare", sender:nil)

handled =true

}

ifshortcutItem.type=="2"{//编辑

letrootNavigationViewController =window!.rootViewControlleras?UINavigationController

letrootViewController = rootNavigationViewController?.viewControllers.firstasUIViewController?

rootNavigationViewController?.popToRootViewControllerAnimated(false)

rootViewController?.performSegueWithIdentifier("toCompose", sender:nil)

handled =true

}

returnhandled

}


https://github.com/itjhDev/itjh_3DTouch

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 3D Touch 概述: 从.Net转来也快有半年之多了,从小生到现在也算是经历了无所bug了,不过还是打到不了I...
    LitterL阅读 828评论 8 1
  • 一、屏幕图标使用3D Touch创建快速进入入口: 1、与之相关的类: (1)、 UIApplicationSho...
    寻形觅影阅读 877评论 0 0
  • 专著:http://www.jianshu.com/p/3443a3b27b2d 1.简单的介绍一下3D Touc...
    violafa阅读 1,111评论 1 0
  • 自从iPhone6s、iPhone6sP出现后,推出了一个新功能,能让你的手指“按到屏幕里面去”,应公司需要,特花...
    mimi不是米阅读 1,150评论 3 9
  • 3D Touch,苹果iPhone 6s的新功能 有Peek Pop 两种新手势 实现点击app出现小弹框界面的方...
    静静的coding阅读 504评论 0 0

友情链接更多精彩内容