티스토리 뷰

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(5as! UILabel
        var button = cell.viewWithTag(27as! 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해주기




댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
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
글 보관함