I want to add two adjacent custom buttons in the UITableView's accessory view.
I tried doing cell.accessoryView = customButton;
and then
cell.accessoryView = customButton2
.It is obvious that this replaces the previous button.
Thanks for any help!
You can add a UIView containing the two buttons as a custom accessoryView.
UIView *buttonsView = [...];
// add buttons to buttonsView
cell.accessoryView = buttonsView;
Or you can subclass UITableViewCell and add two buttons there.
- (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;
}
If you haven't done a custom UITableViewCell before this article might help.
http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702
You can make a custom UIView class with your buttons placed inside of it (as subviews: [self addSubview:button]
). Then you can assign your custom UIView object as accessoryView of a cell.
cell.accessoryView = yourCustomView;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With