美文网首页
iOS__3D-Touch实现UITableViewCell的预

iOS__3D-Touch实现UITableViewCell的预

作者: CoderJohnhao | 来源:发表于2016-12-25 20:09 被阅读93次

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

    Simulator Screen Shot 2016年12月25日 下午7.55.27.png Simulator Screen Shot 2016年12月25日 下午7.55.40.png Simulator Screen Shot 2016年12月25日 下午7.55.43.png

    第一步:遵守UIViewControllerPreviewingDelegate协议


    QQ20161225-0@2x.png

    第二步:设置代理,在UITableView的代理方法cellForRowAtIndexPath

    // 对每个cell指定代理, 大致是这个意思
    [self registerForPreviewingWithDelegate:self sourceView:cell];
    

    第三步:实现UIViewControllerPreviewingDelegate代理方法

    1. -(UIViewController*)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location

    2.-(void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit

    以上三步就可以实现uitableViewCell3D-Touch实现UITableViewCell的预览和跳转

    具体代码请跳转到我的github查看:https://github.com/Johnhao941026/3D-Touch_TabelViewCell

    相关文章

      网友评论

          本文标题:iOS__3D-Touch实现UITableViewCell的预

          本文链接:https://www.haomeiwen.com/subject/hzddvttx.html