1

I decided to addUIContextMenuInteraction to my UITableViewCell, it works fine, but the title that has 9+ letters (without image) or 6+ letters(with image) is getting shortened like this:

enter image description here

Implementation of delegate method:

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])
        }
    }

}
  • 1
    I believe that the recommended approach is to implement `func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?` Tutorial can be found here: https://kylebashour.com/posts/ios-13-context-menus – Daniel Dec 11 '19 at 08:49
  • @Daniel I have followed the tutorial still getting problem with after 6th Character as well – Hrishikesh Devhare Dec 26 '19 at 11:34
  • @Alexander I copied your code for creating the `UIMenu` into an app of mine and could not reproduce the issue. – Daniel Dec 26 '19 at 19:19
  • @Daniel I am able to reproduce the issue in my app as well ins iOs 13.2.2 https://ibb.co/NCwb1fH My tableview is present in view controller which is added as child to another viewController. Can you please check this scenario ? – Hrishikesh Devhare Dec 28 '19 at 04:17
  • In my case, the issue is caused by third party framework ( "SkeletonView") which I had added to give shimmer effect to UITableViewCell – Hrishikesh Devhare Dec 29 '19 at 08:41
  • I agree with @Daniel - better to use the dedicated tableview delegate context menu methods. – Chris Dec 29 '19 at 08:49

1 Answers1

0

Check if any third party framework added to your project for customising the UITableViewCell is breaking the UI. In my case, the issue is caused by third party framework ( "SkeletonView") which I had added to give shimmer effect to UITableViewCell