iOS 指压即达集成iOS9里的3D Touch的方法
iOS9引入了3D Touch技术,通过区分按压力度和时间长短,实现对应的操作、弹出预览等功能。指压即达作为移动营销领域的先驱,也需要在产品中逐渐使用到这项技术,下面是指压即达咨询师对iOS9里的3D Touch集成介绍的详细内容。
一、添加Force Touch功能
1、“Force Touch” 识别类型
iOS9的SDK增加了一个UITouchType识别类型:UITouchTypeStylus。调用系统枚举类型即可判断当前设备是否支持Force Touch:
objC
if ([UITouch respondsToSelector:@selector(type)]) {
if ([[event allTouches] anyObject].type == UITouchTypeStylus) {
// 获取按压力度
}
}
2、接口API
(NSNumber *)force
// the force of the touch, where a value of 1.0 represents the force of an average touch (predetermined by the system, not user-specific)
(CGFloat)maximumPossibleForce
// the force at which the touch delivery is considered a force-click
(objC)CGPoint)preciseLocationInView:(UIView *)view
// the precise location of the touch on the surface, potentially beyond the bounds of the view
(objC)UIFeedbackGenerator
// a new API for providing feedback to the user via haptic vibrations
注意:在iPad Pro上,只要用户使用Apple Pencil书写就能触发Force Touch,不需要在笔尖上施加外力。
二、应用实践
针对于iOS9的3D Touch技术集成,有以下几种应用实践:
1、应用快速入口
在App图标上添加应用菜单,用户可直接在打开App之前,执行某些操作,如直接跳转到搜索、最近聊天等页面,体验更加流畅,提高使用效率。
2、内容排版
在应用内,Force Touch可以实现弹出预览窗口,提高显示效果,如在iPhone 6s/6s Plus的相册中,使用Force Touch即可浏览某张照片的大图,无需完全打开照片,提升界面流畅度,缩短操作时间。
3、效果展示
在应用中,也可以通过Force Touch增加一些展示效果,如在图库中 Force Touch 一个图片后,以弹出的 UIView 上下反复摇晃来提示用户该图片已被收藏,通过简单的互动,提高用户体验。
综上所述,iOS9的3D Touch集成是指压即达产品在移动营销领域更好地提升用户体验的措施之一,下一步指压即达将继续深入挖掘移动营销领域的技术,为用户提供更加满意的体验。
