カスタムUITableViewCell内にUITextFieldがあります。Custom TableView Cell内のUITextFieldがタップされたときの新しいビューへの切り替え
カスタムセル内に座っているUITextFieldをタップすると、新しいView Controllerに接続する必要があります。
未遂ソリューション
私はperformSegueはViewControllerを機能であるbecuaseしかし、これは動作しませんでした
public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
print("Text Field Tapped")
return false
}
を使用してCustomTableViewCellクラス内セグエを行ってみました。次に、MyViewControllerクラスで
func someAction() {
performSegue(withIdentifier: "identifier", sender: self)
}
を試してみましたが、これも機能しませんでした(その理由はわかりません)。これは私の2つのクラスがどのように見えるかです:
MyViewController(のUITableViewを保持している)
import UIKit
class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:SearchTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "cell") as! SearchTableViewCell
return cell
}
}
CustomTableViewCell
import UIKit
class CustomTableViewCell: UITableViewCell, UITextFieldDelegate {
@IBOutlet weak var someTextField: UITextField!
override func awakeFromNib() {
super.awakeFromNib()
self.someTextField.delegate = self
}
}
あなた賢い人々が提供できるすべてのヘルプは大歓迎です:)
本当に助けてくれてありがとう!ありがとう。 Swiftのカスタム検索バーで何か経験があるかどうかはわかりませんが、もしあなたがこの投稿を見ることができたら:http://stackoverflow.com/questions/41641521/swift-custom-searchcontroller-and-searchbar?再度、感謝します! – JordanW