[Swift] Notebook
Swift - CollectionView 페이지 이동하기
Dev2DHs
2016. 4. 19. 14:21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | //ViewController import UIKit class ViewController: UICollectionViewController { var Array = [String]() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. Array = ["소풍","여행","운동회","스키장"] } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return Array.count } override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! UICollectionViewCell var label = cell.viewWithTag(5) as! UILabel var button = cell.viewWithTag(27) as! UIButton button.setTitle(Array[indexPath.row], forState: UIControlState.Normal) label.text = Array[indexPath.row] return cell } } | cs |
Navigation View Controller 에서 Table View 삭제 / CollectionViewController를 연결/
각각의 Collection마다 버튼과 라벨에 대한 값 넣고, 페이지 Show해주기