年代別のクイズアプリを作成しているのですが、ストーリーボードでこの続きを作るとどこのボタンを押しても同じ画面に移ってしまいます。
Button Array を一つずつ別にするには何かコードを加えればいいのでしょうか?
どことどこの間にこのコードをコードをかけばコードを書けばいいなど何かしらアドバイスください
Swift
1import UIKit 2 3class CollectionViewController: UICollectionViewController { 4 5 var Array = [String]() 6 7 var ButtonArray = [String]() 8 9 10 override func viewDidLoad() { 11 super.viewDidLoad() 12 // Do any additional setup after loading the view, typically from a nib. 13 14 Array = ["平成27年","平成27年","平成26年","平成26年","平成25年","平成25年","平成24年","平成24年","平成23年","平成23年","平成22年","平成22年"] 15 16 ButtonArray = ["上期","下期","上期","下期","上期","下期","上期","下期","上期","下期","上期","下期"] 17 18 } 19 20 override func didReceiveMemoryWarning() { 21 super.didReceiveMemoryWarning() 22 // Dispose of any resources that can be recreated. 23 } 24 override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 25 return Array.count 26 } 27 28 override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 29 let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell 30 31 let label = cell.viewWithTag(1) as! UILabel 32 33 label.text = Array[indexPath.row] 34 35 let Button = cell.viewWithTag(2) as! UIButton 36 37 38 Button.setTitle(ButtonArray[indexPath.row], forState: UIControlState.Normal) 39 40 41 42 return cell 43 } 44 45 46}