【问题标题】:Swipe to delete with phonegap使用phonegap滑动删除
【发布时间】:2012-07-13 17:29:36
【问题描述】:

我一直在关注一个教程,该教程最终创建了一个用于在本地存储表单输入数据的 Web 应用程序(您可以在此处查看最终项目:http://mc-mobile-app.s3.amazonaws.com/index.html)。

然后我正在使用这些文件来测试使用 phonegap 和 Xcode 创建本机应用程序 - 但我无法弄清楚如何添加滑动以删除存储的条目(一个接一个,而不是一次性删除所有条目)。

是否可以使用上述工具?如果可以,如何实现?

【问题讨论】:

    标签: xcode html cordova swipe phonegap-build


    【解决方案1】:

    在 tableView 的 'cellForRowAtIndexPath' 委托方法中写入以下内容:

       UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
                                               initWithTarget:self
                                                       action:@selector(handleSwipeLeft)];
       swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
       [cell addGestureRecognizer:swipeLeft];
       [swipeLeft release];
    

    您必须编写一个处理程序“handleSwipeLeft:”,它显示删除按钮,然后在此按钮的单击事件中,您可以编写以下代码来删除表格行:

    [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
    

    其中 indexPaths 是要删除的索引数组... 希望对您有所帮助... :)

    【讨论】:

    • 感谢您的回答 - 该应用是移植到手机间隙的 HTML5 应用 - 可以吗?如果是这样,我在哪里输入该代码?抱歉,这是我第一次尝试 iPhone 应用程序亲切的问候
    【解决方案2】:

    我一直在寻找同样的东西。 我能找到的最接近的是 jQuery-mobile 插件..

    http://www.andymatthews.net/read/2012/02/19/swipeButton-jQuery-Mobile-plugin-launches.-Millions-rejoice!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-23
      • 1970-01-01
      • 2011-04-13
      • 2012-03-17
      • 2021-01-02
      • 2023-03-21
      相关资源
      最近更新 更多