在iOS 8中,如何在UITableViewCell的左侧添加行操作按钮 [英] In iOS 8, how to add Row Action Buttons to the left side of a UITableViewCell

查看:169
本文介绍了在iOS 8中,如何在UITableViewCell的左侧添加行操作按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple在iOS 8的产品页面上显示这些图片。我有兴趣将按钮添加到表格行的左侧,如第一个图片所示。这是一个公共API吗?注意,我已经知道向右侧添加按钮的委托方法。我浏览了WWDC会议视频和文档没有用。

Apple shows these images on their product page for iOS 8. I am interested in adding buttons to the left side of a table row as shown in the first image. Is this a public API? Note that I am already aware of the delegate method for adding buttons to the right side. I've looked through the WWDC session videos and documentation to no avail.

提前感谢。

Pic:左侧的按钮

Pic:右侧按钮

推荐答案

这是一个公开的API到iOS8的点,如解答这里滑动以删除,并且更多按钮(类似于iOS 7上的邮件应用程序)

It's a public API to a point in iOS8, as explained in answers here Swipe to Delete and the "More" button (like in Mail app on iOS 7)

Github上还有一些实现,例如这个由MortimerGoro (上面的答案的一部分)。

There are also several implementations already on Github, such as this one by MortimerGoro (part of the answer above).

如果你想做您可以使用自定义UISCrollView或添加子视图到您的单元格的 contentView 。根据需要添加手势识别器以处理不同的滑动方向。
本质上,当手势进行时,使用负值重新定位按钮子视图,这提供了揭示静态按钮的外观。在现实中,一切都在移动,只是在相反的方向。

If you want to do it yourself, you can use a custom UISCrollView or add subviews to your cell's contentView. Add gesture recognizers as appropriate to handle different swipe directions. Essentially you reposition the button subviews with negative values as the gesture progresses, which gives the appearance of uncovering static buttons. In reality, everything is moving, just in opposite directions.

Ray Wenderlich.com有一个非常深入的教程,了解如何重新创建效果。
它也是一个右侧按钮方法,但概念是相同的 - 只是交换滑动手势的方向&放置按钮子视图的位置。

Ray Wenderlich.com has a very in-depth tutorial for how to recreate the effect. It's also a right-sided button approach, but the concepts are identical - just swap the direction of the swipe gesture & where you place the button subviews.

这篇关于在iOS 8中,如何在UITableViewCell的左侧添加行操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆