下の画像の様にtableと二つのviewcontrollerを結びました。
tableのそれぞれの欄に無名のbuttonを配置しそれをタップすると該当するviewcontrollerに繋がる様にしたいのですが、全てのbuttonが最初のviewcontrollerであるSecondSwitchViewContollerに繋がってしまいます。
これはtableがprototypeな為ですか?それとも何か原因がありますか?教えていただけたら嬉しいです。
SecondViewController
1import UIKit 2import AVFoundation 3import GoogleMobileAds 4 5class SecondViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 6 7 8@IBAction func setting(_ sender: UIButton) 9 { 10 counter = counter + 1 11 print(counter) 12 13 if counter == 1{ 14 self.performSegue(withIdentifier: "nextView", sender: nil) 15 counter = 0 16 } 17 } 18@IBAction func setting(_ sender: UIButton) 19 { 20 counter = counter + 1 21 print(counter) 22 23 if counter == 1{ 24 self.performSegue(withIdentifier: "secondsetting", sender: nil) 25 counter = 0 26 } 27 }
コードを貼りましょう。
貼りました
cellの種類はStatic Cellsですか?Dynamic Prototypesですか?
cellはDynamic Prototypesで、StoryboardのTableViewの上にObjectLibraryからTableViewCellを6回ドラッグ&ドロップしてませんか?
cellの種類はDynamic Prototypesです。6回ドロップしてます。その通りです。
UIButtonとUISwitchも6回ドラッグ&ドロップして、settingViewControllerも6枚作ろうとしていませんか?
返信遅れてすみません。その通りです
狙ってやってるなら、狙い通りにすすめてください。わけもわからずやられてるなら、先ずは仕組みを学習してください。後者の場合に限ってですが、お絵かき帳のようにstoryboardを使っても動くものは出来上がりませんよ。
回答2件
あなたの回答
tips
プレビュー