cell重用机制
实现tableView的连个代理<UITableViewDelegate, UITableViewDataSource>即可,然后实现这两个代理的两个必要方法:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
这两个个方法,第一个是返回要显示的tableView中的cell的个数,第二个是为cell添加数据。其实根据cell的动态复用机制,就能推断出为cell添加数据的函数肯定是执行一次只能添加一个cell的。