苹果2015年发布iPhone 6s带来了全新的用户交互功能: 3D-Touch功能,他能根据用户按压手机屏幕的力度实现一些交互. 本篇文章介绍一下,3D-Touch实现UITableViewCell的预览和长重按跳转.



第一步:遵守UIViewControllerPreviewingDelegate协议

第二步:设置代理,在UITableView的代理方法cellForRowAtIndexPath
// 对每个cell指定代理, 大致是这个意思 [self registerForPreviewingWithDelegate:self sourceView:cell]; 第三步:实现UIViewControllerPreviewingDelegate代理方法
- -(UIViewController*)previewingContext:(id )previewingContext viewControllerForLocation:(CGPoint)location
2.-(void)previewingContext:(id)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
以上三步就可以实现uitableViewCell3D-Touch实现UITableViewCell的预览和跳转
具体代码请跳转到我的github查看:github.com/Johnhao9410…