Mac Catalyst 滑动删除功能在 Mac 上不起作用

kal*_*thi 2 uitableview ios swift mac-catalyst

滑动删除在 中不起作用maccatalyst。相同的代码在 iPad 上运行良好。

UITableview trailingSwipeActionsConfigurationForRowAt中未调用该方法maccatalyst

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
{
 
    if indexPath.row == RestrictedDeletionRoom
    {
        return false
    }
    else
    {
        return true
    }
}

func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    
    if editingStyle == .delete {
        
        tableView.deleteRows(at: [indexPath], with: .fade)
    }
}

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    
    let delete = UIContextualAction(style: .destructive, title: "Delete") { (action, sourceView, completionHandler) in
        
        self.deletedRowDict = self.RoomsListArray.object(at: indexPath.row) as! NSDictionary
        
        if let cell = tableView.cellForRow(at: indexPath) as? RoomsListCellTableViewCell {
            let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let popoverContent = storyboard.instantiateViewController(withIdentifier: "tableViewCellPopUp") as! tableViewCellPopUp
            popoverContent.delegate = self
            popoverContent.modalPresentationStyle = .popover
            popoverContent.view.superview?.layer.cornerRadius = 1
            popoverContent.msgTxt?.text = "Are you sure you want to delete this Room?"
            
            if let popover = popoverContent.popoverPresentationController {
                
                let viewForSource = cell.deleteView
                popover.sourceView = viewForSource
                popover.permittedArrowDirections = .left
                // the position of the popover where it's showed
                popover.sourceRect = (viewForSource?.bounds)!
                
                popoverContent.preferredContentSize = CGSize(width:400,height:65)//
            }
            self.present(popoverContent, animated: true, completion: nil)
        }
        completionHandler(false)
    }
    
    let swipeAction = UISwipeActionsConfiguration(actions: [delete])
    swipeAction.performsFirstActionWithFullSwipe = false
    return swipeAction
}
Run Code Online (Sandbox Code Playgroud)

有谁解决了这个问题吗?

K1w*_*eek 8

您是否尝试使用鼠标向下滑动或通过 Apple 鼠标滚动手势(鼠标上的水平滑动手势)进行滚动滑动?在 Mac Catalyst 上,滑动通常需要鼠标滑动手势,而不是鼠标按下