2011-12-02 65 views

回答

4

你可以從圖像創建一個新的視圖,然後將它添加到調用addSubview的單元中。下面是一個例子一經推出設置角落:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

     CGRect cornerFrame = CGRectMake(x, y, width, height); 
     UIImageView * corner = [[UIImageView alloc] initWithFrame:cornerFrame]; 
     [corner setImage:[UIImage imageNamed:@"corner.jpg"]]; 

     [cell.contentView addSubview:corner]; 
    } 

    return cell; 
} 
+0

這將無法正常工作...細胞得到重用,因此當你以這種方式實現它來添加很多這樣的每個細胞。 –

+0

這就是調用'addSubview'的例子。他可以在任何他想要的地方使用它。 – Dimme

+0

在這個特定的地方,它會突破:)唯一比糟糕的代碼示例更差的代碼示例。 –

0

它可能只是一個在細胞圖像。沒有太花哨的東西,只是你自己的磨坊標準運行自定義UITableViewCell