UITableView 類比android的ListView,指的是擁有相同視圖不同資料的列表.例如的連絡人清單
1.UITableViewDelegate,UITableViewDataSource分別為UITableView的資料與行為的代理.
也就是UITableView本身什麼都不幹,他的資料載入由來實現,而行為由來實現.
2.UITableView的列表分為兩種形式,一種是plain(單列表)形式,一種是Group(列表組)形式.
Group Plain
<喎?http://www.bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+tbHOqrWl1+nB0LHtyrEst7W72DEgtbHOqrbg1+nB0LHtyrEst7W72D4xtcTK/dfWPC9wPgo8cD48L3A+CjxwcmUgY2xhc3M9"brush:java;">- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
根據section為返回的組數判斷.返回每組的列數
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;
這裡有幾個術語需要解釋
Section:組數或者列數
indexPath:indexPath.row表示某組的列數
indexPath.section 表示組數
3.如何顯示列表呢?做過Android-ListView的都知道,該列表的adapter裡面實現了視圖緩衝,某個item只在第一次建立,以後的工作只是重複賦值.在ios中,返回的每個item為UITableViewCell及其子類
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
所以,通過組數 列數 每列的樣式 可以初步顯示整個列表的摸樣.