1.tableView的格式區別
選擇UITableViewStyleGrouped方式會全部顯示,UITableViewStylePlain則在上拉的時候,把組頭頂在頂部。
iOS7中,如果用UITableViewStyleGrouped的話,里面的 cell會比原來的拉長了 (效果和UITableViewStylePlain一樣了),這樣做應該是為了統一和UITableViewStylePlain風格時cell的大小一致,而且在iOS7中,使用UITableViewStyleGrouped風格時,上面會出現 headView ,大概占了35個像素。
2.tableView解決組之間的間隔
@proper(nonatomic) CGFloat sectionHeaderHeight 在delegate未實現tableView:heightForHeaderInSection:方法時才使用。(注:當我們在代理中)
3.UItableViewCell自帶的四種格式
定義自帶屬性值
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString * identifier= @"cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier]; } cell.backgroundColor = [UIColor grayColor]; //自適應圖片(大小) cell.textLabel.text = @"主題"; cell.imageView.image = [UIImage imageNamed:@"關於我們@2x.png"]; cell.detailTextLabel.text = @"副主題"; return cell; }
UITableViewCellStyleDefault(左邊一張圖,一個標題)
UITableViewCellStyleValue1(左邊一張圖 一個主題,右邊副主題)
UITableViewCellStyleValue2(一個主題一個副主題)
UITableViewCellStyleSubtitle(一張圖,一個主題,一個副主題(副主題在主題下面))
我們在開發過程中tableView使用非常廣泛,但是有一些格式我們沒有必要自定義,能夠直接拿出來使用更加方便快捷!