Can you use 3D Touch on widgets?

≡放荡痞女 提交于 2019-12-06 04:11:34

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.

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