更好的辦法上測試使用的UITableView的默認方法:在迅速
-(void)tableView:(UITableView*)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender;
-(BOOL)tableView:(UITableView*)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender;
-(BOOL)tableView:(UITableView*)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath*)indexPath;
及其等價物:
override func tableView(_ tableView: UITableView, canPerformAction action:
Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
if (action.description == "copy:") {
return true
} else {
return false
}
}
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
if (action.description == "copy:") {
//...
}
}
override func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool {
return true
}
歡迎來到Stack Overflow。我已經修復了您的帖子中的一些英文問題。請提供您的代碼示例。 –