2012-02-21 44 views
1

A Quick drawing of what I want擴展的UITableView

的細胞我期待在做延伸,如圖像的另一部分表視圖部分。雖然這是純粹的美學,如果你知道一個簡單的方法做到這一點,我想知道。

回答

1

您的不同部分可以有不同的背景圖像和子視圖的不同框架。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"]; 
    if(cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LOC_ID"]; 
     [cell autorelease]; 
    } 
    if(indexPath.section == 0){ 
     if(indexPath.section == 0 && [self tableView:numberOfRowsInSection:0]-1 == indexPath.section){ 
      //put background image for last row in section 0 
     } else { 
      //backgroundimaes for all other cells in section0 
     } else if(indexPath.section == 1) { 
      //configure section 1 ibackgroundimages 
     } 
    } 

    return cell; 
} 

設置一個細胞

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_bg.png" ]autorelease]; 
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_selected_bg.png"]; 
+0

因此,只需創建一個看起來像這樣的圖像並將其放入單元格中,我喜歡那樣 – 2012-02-22 05:27:37

1

好圖。如果您嘗試創建具有不同寬度的部分的UITableView,那是不可能的。你將不得不使用兩個不同寬度的單獨UITableView,並將其放在另一個之下。或者只是手動設置一些UITableViewCells,根本不使用UITableView。

+0

您是如何使用UITableViewCells沒有一個UITableView的背景嗎? – vikingosegundo 2012-02-21 23:53:53

+0

我以前沒有看到過,但XCode在添加UITableViewCell時沒有問題,因爲沒有UITableView – 2012-02-22 05:26:11