是否可以以编程方式在 UITableViewCell 上显示红色删除按钮?
这里有很多类似的问题,但我认为没有一个专门问这个问题,即代码中是否有任何方法可以强制红色删除按钮出现在 UITableView 行的右侧?
我问的原因是我试图使用两个 UISwipeGestureRecognizer 来更改 tableview 的行为,以便:
单指滑动会调用自定义操作(而不是导致显示红色删除按钮,这就是它的方式)现在的行为),并且
双指滑动调用默认的单指操作- 手指滑动行为,即导致显示红色删除按钮。
我已经浏览了 SDK 文档,但我找不到任何导致该红色按钮出现的方法,这让我认为如果不从头开始手动创建红色删除按钮并尝试使上面提议的 UI 方案不可能实现它模仿内置行为。
非常感谢任何帮助。
There are lots of similar questions on here, but none that I think specifically ask this question, which is, is there any way in code to force the red delete button to appear at the right-side of a UITableView row?
The reason I ask is that I'm trying to change the behaviour of a tableview using two UISwipeGestureRecognizers such that:
a single-finger swipe invokes a custom action (instead of causing the red delete button to show, which is how it behaves now), and
a double-finger swipe invokes the default single-finger swipe behaviour, i.e. causes the red delete button to show.
I have scoured through the SDK docs but I can't find any way of causing that red button to appear, which makes me think that the proposed UI scheme above is impossible to implement without manually creating the red delete button from scratch and trying to make it emulate the built-in one's behaviour.
Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 doubleFingerSwipe 手势的选择器方法中,设置一个变量并指定为滑动的行数并重新加载表格。
在
我认为这对你的问题有用。
In the doubleFingerSwipe gesture's selector method set one variable and assign as no of row swiped and reload the table .
In the
I think thats work for ur problem.
这不是对您问题的回答,而是关于功能的建议(我还不能发表评论,但我仍然想提供我的两分钱)。
从 UI/UX 角度来看,覆盖默认或“预期”功能并不是一个好主意。用户对各种应用程序和功能如何工作有一定的期望,当它们不以这种方式工作时,用户要么会感到沮丧或困惑。因此,几乎每个涉及表视图的应用程序中的下拉刷新功能都在激增。更有意义的是将两指滑动作为自定义功能。那么你的应用程序不仅会符合传统的用户体验指南(事实上,我认为苹果可能会拒绝你的应用程序,这可能就是你很难找到答案的原因),而且它会涉及很多更少的挣扎/自定义代码。
很抱歉,这不是您问题的直接答案,但我希望它能有所帮助。
This is not an answer to your question, but a suggestion about the functionality (I can't leave comments yet, but I would still like to offer my two cents).
From a UI/UX perspective, overriding the default or "expected" functionality is not a great idea. Users have certain expectations about how various apps and features will work, and when they don't work in that manner, the users either get frustrated or confused. Hence the proliferation of the pull-to-refresh functionality in nearly every app that involves a table view. What would make more sense would be to have the two-finger swipe be the custom functionality. Not only would your app then conform to traditional UX guidelines (in fact, I think Apple might reject your app as it stands, and that is probably why you're having such a hard time finding an answer), but it would involve a lot less struggle/custom code.
So sorry that wasn't a direct answer to your question, but I hope it helps.
通过调用
UITableViewController,您可以将 tableView 设置为编辑模式。您实际上可以将手势识别器添加到单元格视图中,该单元格视图使用委托方法进行调用。
根据UITableViewCell的文档UITableViewCell您实际上可以以相同的方式设置单个单元格。除此之外,您还必须管理标准手势识别器。我想在这种情况下子类化将是你的盟友。
我希望这有帮助。
By calling
on a UITableViewController you can set the tableView to editing mode. you can actually add a gesture recognizer to the cell a cell view that makes that call using a delegate method.
According to the Documentation of UITableViewCell you can actually set the same way an individual cell. Apart from that you will have to manage the standard gesture recognizer. I guess subclassing would be your ally on that situation.
I hope this helps.