iOS - 如何查看“滑动删除"功能对表视图单元格的操作? [英] iOS - How To Give A Peek At The "Swipe To Delete" Action On A Table View Cell?

查看:28
本文介绍了iOS - 如何查看“滑动删除"功能对表视图单元格的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当某个Table View Controller第一次显示时,如何简单的显示某个表格行中存在红色的滑动删除"功能?

When a certain Table View Controller displays for the first time, how to briefly show that the red "swipe to delete" functionality exists in a table row?

以编程方式玩躲猫猫的目的是向用户展示该功能的存在.

The goal of programmatically playing peekaboo with this is to show the user that the functionality exists.

环境:iOS 11+ 和 iPhone 应用.

Environment: iOS 11+ and iPhone app.

这是一张显示单元格滑动到一半的图像,带有一个基本的滑动删除"红色操作按钮.

Here's an image showing the cell slid partway with a basic "swipe to delete" red action button.

一位开发人员友好地提到了 SwipeCellKit,但 SwipeCellKit 有很多.我们想要做的只是简单地模拟部分滑动,让用户知道滑动删除"的存在.换句话说,我们希望在单元格下的删除操作中提供一个潜行高峰.

A fellow developer kindly mentioned SwipeCellKit, but there’s a lot to SwipeCellKit. All we want to do is briefly simulate a partial swipe to let the user know the "swipe to delete" exists. In other words, we want to provide a sneak peak at the delete action under the cell.

如果有帮助,这里是SwipeCellKit 的 showSwipe 代码 这是一个 链接及其使用示例.

In case it helps, here's the link to the SwipeCellKit's showSwipe code Here is a link with an example of its use.

我查看了 SwipeCellKit 源代码.我不清楚如何在没有 SwipeCellKit 的情况下做到这一点.此外,目前还不能使用 SwipeCellKit.

I looked at the SwipeCellKit source code. It's not clear to me how to do it without SwipeCellKit. Also, Using SwipeCellKit is not currently an option.

谷歌搜索没有帮助.我一直在遇到如何添加滑动操作,但不知道如何简要展示向用户滑动单元格下的滑动操作,即 UITableViewRowAction 项.

Googling hasn't helped. I keep running into how to add swipe actions, but not how to briefly show the Swipe Actions aka UITableViewRowAction items that are under the cell to the user.

如何向用户简要展示这个内置的滑动删除"操作?

How to briefly show this built in "swipe to delete" action to the user?

推荐答案

我很确定这是不可能的.滑动操作包含在 UISwipeActionPullView 中,其中包含 UISwipeStandardAction 子视图,这两个子视图都是私有的.它们也是表格视图的一部分,而不是单元格,除非发生手势,否则不会添加它们,因此您不能只是将单元格撞到一侧并在那里看到它们.

I'm pretty sure this can't be done. The swipe actions are contained in a UISwipeActionPullView, which contains UISwipeStandardAction subviews, both of which are private. They are also part of the table view, not the cell, and they're not added unless a gesture is happening, so you can't just bump the cell to one side and see them there.

在 UI 自动化测试之外,不使用私有 API 就无法模拟用户手势,因此您无法伪造"滑动然后向用户显示结果.

Outside of UI automation tests, it isn't possible to simulate user gestures without using private API, so you can't "fake" a swipe and then show the results to the user.

但是,当您可以作弊时,为什么还要正确"地做呢?将单元格的内容视图稍微向左弹跳应该不会太难,并在红色框中弹跳(不要远到您可以看到文本,以避免本地化问题),然后恢复正常.在第一次加载 table view 时执行此操作,并在 N 次后或在用户证明他们知道此特定 iOS 约定如何工作后停止执行此操作.

However, why bother doing it "properly" when you can cheat? It shouldn't be too hard to bounce the cell's content view slightly to the left, and bounce in a red box (not so far that you can see text, to avoid localisation issues), then return to normal. Do this on the first load of the table view, and stop doing it after N times or after the user has proven that they know how this particular iOS convention works.

这篇关于iOS - 如何查看“滑动删除"功能对表视图单元格的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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