【问题标题】:ios 13 UIContextMenu shows shortened UIAction titlesios 13 UIContextMenu 显示缩短的 UIAction 标题
【发布时间】:2020-03-30 10:46:21
【问题描述】:

我决定将UIContextMenuInteraction 添加到我的UITableViewCell,它可以正常工作,但是包含 9+ 个字母(无图像)或 6+ 个字母(有图像)的标题会像这样缩短:

委托方法的实现:

extension MyCustomCell: UIContextMenuInteractionDelegate {

    @available(iOS 13.0, *)
    func contextMenuInteraction(_ interaction: UIContextMenuInteraction,
                                configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
        return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ -> UIMenu in
            let first = UIAction(title: "8Letters") { _ in
                print("8 letters")
            }
            let second = UIAction(title: "9Letters+") { _ in
                print("9 letters")
            }
            let third = UIAction(title: "Hello", image: UIImage(systemName: "square.and.arrow.up")) { _ in
                print("5 letters + image")
            }
            let fourth = UIAction(title: "Hello+", image: UIImage(systemName: "square.and.arrow.up")) { _ in
                print("6 letters + image")
            }
            return UIMenu(title: "", children: [first, second, third, fourth])
        }
    }

}

【问题讨论】:

  • 我认为推荐的做法是实现func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? 教程可以在这里找到:kylebashour.com/posts/ios-13-context-menus
  • @Daniel 我已按照教程操作,但在第 6 个字符之后仍然遇到问题
  • @Alexander 我将您用于创建UIMenu 的代码复制到我的应用程序中,但无法重现该问题。
  • @Daniel 我能够在我的应用程序以及 iOs 13.2.2 ibb.co/NCwb1fH 中重现该问题,我的 tableview 存在于视图控制器中,该视图控制器作为子视图添加到另一个视图控制器。你能检查一下这个场景吗?
  • 在我的情况下,问题是由我添加的第三方框架(“SkeletonView”)引起的,以便为 UITableViewCell 提供微光效果

标签: ios swift ios13 ios13.2 uicontextmenuinteraction


【解决方案1】:

检查添加到您的项目以自定义 UITableViewCell 的任何第三方框架是否会破坏 UI。在我的情况下,问题是由我添加的第三方框架(“SkeletonView”)引起的,以便为 UITableViewCell 提供微光效果

【讨论】:

    猜你喜欢
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多