Tweetie喜欢滑动菜单 [英] Tweetie like swipe menu
问题描述
如何实现tweetie像滑动菜单?
How can I implement tweetie like swipe menu?
我已经完成了使用customcell开发tableviewcontroller。 customcell实现了touchesbegan和touchesMoved。它还通过一个选择器向父tableviewcontroller报告滑动手势。
I'm done with developing a tableviewcontroller with a customcell. The customcell implements touchesbegan and touchesMoved. It also reports swipe gestures via a selector to the parent tableviewcontroller.
现在,我应该如何隐藏Swiped单元格并将其替换为滑动菜单视图如何从swipeview上的按钮获取操作?
Now how should I go about hiding the "Swiped" cell and replacing it with a "swipe menu view" and how should I get the actions from the buttons present on the swipeview?
推荐答案
每个表视图单元格都有一个contentView,整个区域的细胞。将滑动菜单视图添加为具有内容视图不透明背景的单个容器视图,因此它位于其他所有视图之上。将其定位为左对齐(x = 0),将宽度设置为0,并将其设置为隐藏。该单个容器可以包含任何其他子视图(按钮等),您可以将单元格视图本身设置为按钮事件的目标(然后将其向上滚动到父表视图以及单元格索引信息)。
Each table view cell has a contentView that encompasses the whole area of the cell. Add your swipe-menu view as a single container view with an opaque background to the contentview so it's on top of everything else. Position it so it's flush left (x=0), set the width to 0, and set it as hidden. That single container can include any other subview (buttons, etc) and you can set the cell view itself as the target of the button events (then bubble it up to the parent table view along with cell index information).
当时间到来显示它,设置为不隐藏,然后使用UIView动画,使容器宽度从0到完整的表格宽度。设置持续时间相当低(即0.2秒),所以它的zippy。运行动画时,滑动菜单会显示在单元格内容视图中的其他位置。要使它消失只是反向它(在UIView BeginAnimation块中将宽度设置为0)。您可能还想在最后设置一个动画完成处理程序,并在那里进行一些内务处理(将容器视图设置为隐藏,释放内存等)。
When time comes to show it, set it to not hidden then use UIView animation to make the container width go from 0 to full table width. Set the duration pretty low (i.e. 0.2 seconds) so it's zippy. When you run the animation, the swipe-menu shows up over everything else in the cell content view. To make it disappear just reverse it (set the width to 0 in a UIView BeginAnimation block). You may also want to set an animation completion handler at the end and do some housekeeping there (set the container view to hidden, release memory, etc).
这篇关于Tweetie喜欢滑动菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!