cf) Working with UITableView in Xcode 5 Using Storyboard


 

 

TableView 에 데이터를 출력하기 위해선 UITableViewDataSource, UITableViewDelegate 프로토콜을 따라야 한다.

 

 

UITableViewDataSource

 

UITableView는 Table View를 구현하는 실제적인 클래스 이다. UITableView는 다양한 데이터 타입을 다룰 수 있도록 유현하게 구현되어 있다.UITableView에게 데이터를 출력하도록 전달해야 하는데 이때 사용하는 것이 UITableViewDataSource이다.

UITableViewDataSource는 출력할 데이터와 Table View를 연결시켜준다.

 

UITableViewDataSource는 필수적으로 구현해야할 두개의 메소드를 갖는다.

- tableView:cellForRowAtIndexPath

- tableView:numberOfRowsInSection

 

 

UITableViewDelegate

 

UITableView의 외관을 다룬다. 선택적 구현 메소드를 포함하고 있으며 table row의 높이, headings, footers, re-order cells 등의 동작을 구현한다.





UITableViewController


Table View Controller 를 위한 클래스. Table View Controller 와 클래스를 연결 시킬때 UITableViewController를 상속받은 클래스를 만든 후 연결시켜 주자.




Prototype cells



Object Library 에서 UITableViewController를 storyboard로 추가 하였을 때 table view에 기본적으로 보이는 셀이다. storyboard에서 table view cell을 쉽게 편집할 수 있도록 해준다.



Attributes inspector - Style - Subtitle




style 값을 Subtitle 으로 하면 cell 이 2개의 label을 갖게 된다. (UITableViewCellStyleSubtitle)

Title 은 textLabel, Subtitle 은 detailTextLabel 프로퍼티로 정의 된다.


※ reuse identifier ?! 







 

@

Posted by six605
,