CS193p 斯坦福IOS开发 2011 (九)

2019-02-14  本文已影响0人  ItchyHiker

这节课讲了如何展示动态数据列表/固定数据列表

UITableView

展示多维表

使用包含多个MVC的UINavigationController

UITableView的类型

Screen Shot 2019-02-14 at 11.38.09 AM.png Screen Shot 2019-02-14 at 11.38.01 AM.png

UITableView属性

delegate控制UITableView怎么展示,dataSource 控制UITableView展示什么

多少row多少个section

- (NSInteger)numberOfSectionsInTableView:(UITableView *)sender;
- (NSInteger)tableView:(UITableView *)sender numberOfRowsInSection:(NSInteger)section;

UITableView delegate

- (void)tableView:(UITableView *)sender didSelectRowAtIndexPath:(NSIndexPath *)path {
 // go do something based on information
// about my data structure corresponding to indexPath.row in indexPath.section
}

Table View Segue

使用Segue可以在不同Table View之间进行跳转

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
// prepare segue.destinationController to display based on information
// about my data structure corresponding to indexPath.row in indexPath.section }
上一篇 下一篇

猜你喜欢

热点阅读