UITableView

什麼是UITableView

在衆多移動應用中,能看到各式各樣的列表數據性能

 

在iOS中,要實現展現列表數據,最經常使用的作法就是使用UITableView
UITableView繼承自UIScrollView,所以支持垂直滾動,並且性能極佳spa

 

UITableView的兩種樣式

 

如何展現數據

UITableView須要一個數據源(dataSource)來顯示數據3d

UITableView會向數據源查詢一共有多少行數據以及每一行顯示什麼數據等對象

沒有設置數據源的UITableView只是個空殼blog

凡是遵照UITableViewDataSource協議的OC對象,均可以是UITableView的數據源繼承

 

tableView和數據源

 

tableView展現數據的過程

1.調用數據源的下面方法得知一共有多少組數據
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;io

2.調用數據源的下面方法得知每一組有多少行數據
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;table

3.調用數據源的下面方法得知每一行顯示什麼內容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法

相關文章
相關標籤/搜索