現在texitview(1つ)を設置したカスタムセルを
section: 1 row: 0 に設置してあります
このtextviewの値が編集され編集ボタンが押された時に値を取得したいです
値が表示されているカスタムセル
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { else if indexPath.section == 1{ let cell2 = editTableView.dequeueReusableCell(withIdentifier: "editCell2", for: indexPath) as! customTableViewCell cell2.textView2.text = "あいうえお" } }
試した事①
@IBAction func editButton(_ sender: Any) { let customcell = editTableView.cellForRow(at: [1, 0]) textView2 = customCell?.contentView.viewWithTag(2) as? UITextView print(textView.text!) }
発生したエラー
print(textView.text!) の所で
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
試した事②
class edit: UIViewController, UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate { var cell2: cell2! override func viewDidLoad() { super.viewDidLoad() let indexpath: IndexPath = IndexPath(row: 0, section: 0) let cell2 = editTableView.dequeueReusableCell(withIdentifier: "editCell2", for: indexpath) as! customTableViewCell
発生したエラー
var cell2: cell2! の所で
Use of undeclared type 'cell2'
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。