重置我有一個按鈕,彈出一個對話框有兩個按鈕和一個tableView。 tableView是使用自定義的UIView顯示的,而UITableViewCell也是自定義的。 UITableViewCell由一個自定義複選框和一個UILabel組成。我試圖向tableView添加一個點擊手勢,這樣當我點擊一行時,它會標記複選框。此功能還挺作品,但是當我按下了更多然後3秒的UITableViewCell重置這個Swift UiTableViewCell在我的主視圖控制器長按
UITableViewCell Error ScreenShot
我不知道什麼導致此錯誤。任何幫助,將不勝感激。
這是我在我的ViewController代碼,打開彈出對話框:用的tableView
func locationButtonPressed(sender: UIBarButtonItem) {
// Create a custom view controller
let vc = RadiusViewController(nibName: "RadiusViewController", bundle: nil)
// Create the dialog
let popup = PopupDialog(viewController: vc, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
// create first button
let cancelButton = CancelButton(title: "Cancel", height: 60, dismissOnTap: true) {
print("Popup Canceled")
}
// create second button
let okButton = DefaultButton(title: "Ok", height: 60, dismissOnTap: true) {
print("Ok button pressed")
}
// add buttons to dialog
popup.addButtons([cancelButton, okButton])
// present dialog
self.present(popup, animated: true, completion: nil)
print("location button pressed")
}
點觸手勢功能在我的自定義的UIView:
override func viewDidLoad() {
super.viewDidLoad()
...code
let tap = UITapGestureRecognizer(target: self, action: #selector(tableTapped))
self.tableView.addGestureRecognizer(tap)
}
func tableTapped(tap:UITapGestureRecognizer) {
let location = tap.location(in: self.tableView)
let path = self.tableView.indexPathForRow(at: location)
if let indexPathForRow = path {
self.tableView(self.tableView, didSelectRowAt: indexPathForRow)
print("Tapped on the table")
} else {
// handle tap on empty space below existing rows however you want
}
}
我該怎麼做呢? – satish99