基本使用方法

UITableView 基本使用方法总结

时光怂恿深爱的人放手 提交于 2019-12-01 05:34:16
1. 首先,Controller需要实现两个 delegate ,分别是 UITableViewDelegate 和 UITableViewDataSource 2.然后 UITableView对象的 delegate要设置为 self。 3. 然后就可以实现这些delegate的一些方法拉。 (1)- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; 这个方法返回 tableview 有多少个section [cpp] view plain copy //返回有多少个Sections - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } (2)- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section; 这个方法返回 对应的section有多少个元素,也就是多少行。 [cpp] view plain copy - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {