Mình thấy table view cực kỳ đơn giản. Chỉ cần bạn siêng xíu thôi.
Tổng quan như thế này, tableView là 1 cái view, chính xác là 1 view [IMG]images/smilies/smile.png[/IMG]
Gồm nhiều section, mỗi section có nhiều cell. Mỗi cell cũng là 1 view thôi.
TableView có 2 protocols: UITableViewDatasource và UITableViewDelegate.
và 2 thuộc tính datasource và delegate
Muốn set dữ liệu cho 1 table view, chúng ta adopt protocols UITableViewDatasource, có 4 methods chính cần được triển khai:
Mã:
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView;- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Muốn bắt sự kiện tap vào 1 cell thì adopt protocols UITableViewDelegate, method cần quan tâm:
Mã:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
Và còn nhiều phương thức khác trong 2 protocols trên mà bạn nên tìm hiểu [IMG]images/smilies/smile.png[/IMG]
Adopts hay triển khai các phương thức trong 2 protocols như thế nào thì bạn tìm đọc trong cuốn beginning iphone 4 development, có hẳn 1 phần table view để bạn xem đó, rất dễ hiểu.
Chúc bạn thành công.
P/S: bạn có thể down sample của apple tại
Mã:
https://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007318
về xem nhé
Thân.
Ngoại trừ một số ít trường hợp rãnh mũi - má và “râu rồng silicon” xuất hiện sớm, có khi từ tuổi thanh niên do cơ địa, còn lại, đại đa số do căn do lão hoá đã gây nên ba diễn biến: Giảm mô xương gò...
Cách thẩm mỹ má ở tuổi trung niên...