TableViewCellにボタンをつけてボタンを押すと次の画面に遷移するようにしたくて現在コードを書いています。
swift
1import UIKit 2 3class SecondViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 4 5 @IBOutlet weak var tableView: UITableView! 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 } 10 11 override func didReceiveMemoryWarning() { 12 super.didReceiveMemoryWarning() 13 } 14 15 @IBAction func tapButton(_ sender: Any) { 16 performSegue(withIdentifier: "toNextView", sender: true) 17 } 18 19 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 20 return 0 21 } 22 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 23 let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) 24 return cell 25 } 26 } 27
これではボタンが表示されず何もできない状況です。
UITableViewCellを継承したクラスを作ってボタンのコードを書いてみましたがダメでした。
できれば上記のコードを元に作りたいのですが何か良い方法はあるでしょうか?
やはりセルのクラスを作ってやるしかないのでしょうか?
作りたいアプリのイメージはこんな感じで、真ん中のテキストは不要です。
右のボタンは1、2、3で3行目まででそのボタンを押すと画面遷移をするようにしたいです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/05 01:10