2014-02-27 38 views

回答

3

您可以添加一個包含兩個按鈕的UIView作爲自定義的accessoryView。

UIView *buttonsView = [...]; 
// add buttons to buttonsView 
cell.accessoryView = buttonsView; 

或者你可以繼承UITableViewCell並在其中添加兩個按鈕。

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 

    if (self) { 
     UIButton *buttonA = .... 
     UIButton *buttonB = .... 
     [self.contentView addSubview:buttonA]; 
     [self.contentView addSubview:buttonB]; 
    } 

    return self; 
} 

如果您尚未完成自定義UITableViewCell,本文可能會有所幫助。

http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702

1

你可以用你的按鍵的自定義UIView類放在它裏面(如子視圖:[self addSubview:button])。然後,您可以將您的自定義UIView對象指定爲cellView的accessoryView。

cell.accessoryView = yourCustomView;

相關問題