Ios UITableVIewCell,滑动时显示编辑联系人按钮
如何在UITableViewCell上滑动时显示“编辑联系人”按钮?事件不会引发,编辑按钮也不会出现。对于Swift 4和iOS 11+Ios UITableVIewCell,滑动时显示编辑联系人按钮,ios,uitableview,cocoa-touch,uikit,Ios,Uitableview,Cocoa Touch,Uikit,如何在UITableViewCell上滑动时显示“编辑联系人”按钮?事件不会引发,编辑按钮也不会出现。对于Swift 4和iOS 11+ func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { // since the style is destructive,
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// since the style is destructive, so it will have a red background by default.
// change it to .normal and it will have a blue background by default..
let editAction = UIContextualAction(style: .destructive, title: "Edit Contact") { _, _, complete in
// continue your logic..
// write your code to move to next screen.. Perform segue or move using storyboards..
complete(true)
}
// if you want to add icon, then you can do it this way..
editAction.image = UIImage(named: "editContact")
// you can set your own background color for the button like this..
editAction.backgroundColor = .orange
let configuration = UISwipeActionsConfiguration(actions: [editAction])
//set to false to prevent a full swipe from performing the first action..
configuration.performsFirstActionWithFullSwipe = true
return configuration
}
另外,我想为编辑联系人VC添加导航VC,并想将其与TableViewCell@NaveDulHassan5中的我的EditContact滑动按钮链接。我想使用滑动EditContact按钮从联系人屏幕导航到编辑联系人屏幕,这就是我想要的//我正试图根据单击的tableView单元格显示一个viewController//当前,如果它们都被单击,它们将重定向到同一个viewController,我将如何更改它?扩展设置svc:TableViewNew{func onClickCell(index:Int){let aboutusVC=aboutusVC()self.navigationController?.pushViewController(aboutusVC,动画:true)let tncVc=TermsAndConditionsVC()self.navigationController?.pushViewController(tncVc,动画:true)}