Hello,
I am testing an existing app on iOS 26. It hast an UITableViewController
that shows a custom context menu preview using previewForHighlightingContextMenuWithConfiguration
and providing an UITargetedPreview
. Something along the lines like this (shortened):
public override func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
guard let indexPath = configuration.identifier as? NSIndexPath
else { return nil }
let previewTableViewCell = self.getCell(for: indexPath)
var cellHeight = self.getCellHeight(for: indexPath, with: maxTextWidth)
// Use the contentView of the UITableViewCell as a preview view
let previewMessageView = previewTableViewCell.contentView
previewMessageView.frame = CGRect(x: 0, y: 0, width: maxPreviewWidth, height: cellHeight)
previewMessageView.layer.masksToBounds = true
let accessoryView = ...
let totalAccessoryFrameHeight = accessoryView.frame.maxY - cellHeight
var containerView = UIView(frame: .init(x: 0, y: 0, width: Int(maxPreviewWidth), height: Int(cellHeight + totalAccessoryFrameHeight)))
containerView.backgroundColor = .clear
containerView.addSubview(previewMessageView)
containerView.addSubview(accessoryView)
// Create a preview target which allows us to have a transparent background
let previewTarget = UIPreviewTarget(container: tableView, center: ...)
let previewParameter = UIPreviewParameters()
// Remove the background and the drop shadow from our custom preview view
previewParameter.backgroundColor = .clear
previewParameter.shadowPath = UIBezierPath()
return UITargetedPreview(view: containerView, parameters: previewParameter, target: previewTarget)
}
On iOS 18 and below this works fine and buttons that are included in the accessoryView
are tapable by the user. Now on iOS 26 the preview is shown correct (although it has a bit weird shadow animation), but tapping a button of the accessoryView
now closes the context menu, without triggering the touchUpInside
event anymore.
For me it feels like an unintended change in behavior, but maybe I am missing something?
Filed FB18644353