Can you use 3D Touch on widgets?

馋奶兔 提交于 2020-01-13 14:59:02

问题


I am thinking about creating an iOS app that will have a notifications center extension. However I need my app to use 3D Touch on the extension within the Notification Center, is it possible?


回答1:


To my knowledge, you cannot. From apple documentation, it appears the feature is only available in app and on the homescreen:

A user can now press your Home screen icon to immediately access functionality provided by your app. Within your app, a user can now press views to see previews of additional content and gain accelerated access to features.

For experimentation sake, try enrolling the view controller with touch ID using

override func viewDidLoad() {
     if( traitCollection.forceTouchCapability == .Available){        
           registerForPreviewingWithDelegate(self, sourceView: view)         
     } 
}

And you will get an error as TodayViewController will not conform to these protocols. That might be something to add in the future, but it does not look currently supported, most likely because "Today Widgets" are to be as simple as possible.

EDIT: As of iOS 10, this is not only possible but preferred functionality in widgets. Standard documentation will tell you how to implement.



来源:https://stackoverflow.com/questions/36732641/can-you-use-3d-touch-on-widgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!