iphone - How can we add button in custom cell? -
I need to add a button cell have been working in an app and Kstmsel I do not help me for it Could? Thanks in advance
Add you use Customcell the following code in a button. First, with the subclass of UITableViewCell and then @interface CustomCell file Customcell.h Add new file: UITableViewCell {UIButton * customButton; } @property (nonatomic, retaining) UIButton * customButton;
Customcell.m @implementationCustomCell; @ Custom button synthesis; - initWithStyle (ID): (UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier {if ((self = [super initWithStyle: Style reuseIdentifier: reuseIdentifier])) {customButton = [UIButton buttonWithType: UIButtonTypeCustom]; [Custom button set image: [UIImage imageNamed: @ "phonecall.png"] forState: UIControlStateNormal]; } Healthy return; } // Layout set in subview - (zero) layout subviews {[Super layout slideshow]; CGRT ContractRect = Spring. Content view Bounce; CGflat bound x = contentRect.origin.x; CGFloat Bandit = contentRect.origin.y; CGRect frame 1; Frame1 = CGRactack (boundsx + 10, bound + 58, 19, 18); CustomButton.frame = frame1; } #import "CustomCell.h" Cellferroatti & Expath Method // Customize the number of cells in the table view. - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {static NSString * CellIdentifier = @ "cell"; CustomCell * cell = [[[CustomCell alloc] initWithFrame: CGRectZero reuseIdentifier: CellIdentifier] autorelease]; If (cell == zero) {cell = [[[CustomCell alloc] initWithFrame: CGRectZero reuseIdentifier: CellIdentifier] autorelease]; } [Cell.customButton addTarget: Autocomplete: @Selector (callout :) Control events: UIControlEventTouchUpInside]; Return cell; }
Comments
Post a Comment