// ? ?UITableView // ? ?UITableView繼承于UIScrollView,可以滾動(dòng)。 UITableView的每一條數(shù)據(jù)對(duì)應(yīng)的單元格叫做Cell,是UITableViewCell一個(gè)對(duì)象,繼承于UIView紧卒。 // ? ?UITabbeView可以分區(qū)顯?示, 每一個(gè)分區(qū)稱為section, 每一?稱為row, 編號(hào)都從0開始师妙。 系統(tǒng)提供了一個(gè)專門的類來(lái)整合section和row,叫做NSIndexPath。
//創(chuàng)建UITableView
? ?UITableView *tableView = [[UITableView alloc] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?initWithFrame:self.view.bounds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?style:UITableViewStylePlain]; ? ?[self.view addSubview:tableView]; ? ?[tableView release];
//UITableView的樣式枚舉
? // UITableView的初始化?方法包含?一個(gè)UITableViewStyle類型的參數(shù) 這是?一個(gè)枚舉類型 ? ?typedef NS_ENUM(NSInteger, UITableViewStyle) { ? ? ? ?UITableViewStylePlain, ? ? ? ?UITableViewStyleGrouped ? ?};
//UITableView的相關(guān)屬性
? ?//rowHeight ? ? ? ?行高
? ?//separtorStyle ? ?分隔線樣式
? ?//separtorColor ? ?分隔線顏?
? ?//tableHeaderView ?UITableView的置頂視圖
? ?//tableFooterView ?UITableView的置底視圖
//UITableView中有兩個(gè)重要的屬性:
? ?@property (nonatomic, weak, nullable) id ? ? dataSource;
? ? //dataSource 顯示數(shù)據(jù)相關(guān)的代理 ? ?@property (nonatomic, weak, nullable) id ? ? delegate;
? ? //delegate ? 視圖操作相關(guān)的代理
//UITableView代理的實(shí)現(xiàn)代碼
? ?1.簽訂UITableView協(xié)議 ? ?2.設(shè)置當(dāng)前的ViewController為 UITableView
//UITableViewCell
? ?//UITableView的每一個(gè)單元格是UITableViewCell類的對(duì) UITableViewCell默認(rèn)提供了3個(gè)視圖屬性:
? ?UIImageView *imageView ?圖片視圖
? ?UILabel *textLabel ? ? ?標(biāo)題視圖
? ?UILabel *detailTextLabel 副標(biāo)題視圖
//UITableView重用cell的代碼流程
? ?1. 在創(chuàng)建UITableView之后,需要注冊(cè)一個(gè)cell類,當(dāng)重用池中沒(méi)有 cell的時(shí)候,系統(tǒng)可以自動(dòng)創(chuàng)建cell镀虐。 相關(guān)方法: ? ?- (void)registerClass:(Class)cellClass forCellReuseIdentifier: (NSString *)identifier; ? ?2.系統(tǒng)提供了一個(gè)獲取重?用池中cell的?方法(需要提供一個(gè)重用標(biāo) 識(shí)): ? ?- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
//UITableViewController
? ?UITableViewController是繼承于UITableViewController中的一個(gè) 類,只不過(guò)?比UITableViewController中多了一個(gè)屬性tableView箱蟆。 即:UITableViewController是一個(gè)自帶table的視圖控制器。
//
? ?一:UITableViewController繼承自UITableViewController,自帶 一個(gè)??ableVie?? ? ?二:[self.view]不是UIView而是UITableView ? ?三:datasource和delegate默認(rèn)都是 self(UITableViewController) ? ?四:開發(fā)中只需要建立UITableViewController子類