swift4のtableviewを表示して、セルごとに入力画面を用意したいのですが、コードのみの実装したパターンが検索しても出てきません。
どうかご教授ください。
swift
1 extension addview: UITableViewDataSource { 2 3 // セクションごとにデータ要素数 4 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 5 return data.count 6 } 7 8 /*// セクション数 9 func numberOfSections(in tableView: UITableView) -> Int { 10 return sectionName.count 11 } 12 13 // セクションヘッダ 14 func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 15 return sectionName[section] 16 } 17 */ 18 19 // セルの高さ 20 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 21 return 40 22 } 23 24 // セル生成 25 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 26 let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 27 28 cell.textLabel?.text = data[indexPath.row] 29 30 date.frame = CGRect(x: cell.frame.midX, y: cell.frame.minY, width: view.frame.width - 220, height: 30) 31 //改行ボタンを完了ボタンに変更 32 date.returnKeyType = .done 33 //文字が何も入力されていない時に表示される文字(薄っすら見える文字) 34 //textfield.placeholder = "FPS" 35 //viewにtextfieldをsubviewとして追加 36 view.addSubview(date) 37 38 39 //cell.accessoryType = .disclosureIndicator 40 //cell.accessoryView = UISwitch() // スィッチ 41 42 return cell 43 } 44 45 46 } 47
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。