I have a table, and I want each cell to contain, besides a bit of text (textLabel) and a picture (imageView), also two custom buttons that would respod to clicks. But they won't show up.
What I did was create a subclass of UIView, to which I added the buttons. I gave the buttons text to display. I called sizeToFit on each button, and then on the container. Then, I added the new view to the cell as accessoryView. I ran the program, and saw that my effort was for naught.
The view I want to see:
The cell:
What I did was create a subclass of UIView, to which I added the buttons. I gave the buttons text to display. I called sizeToFit on each button, and then on the container. Then, I added the new view to the cell as accessoryView. I ran the program, and saw that my effort was for naught.
The view I want to see:
PHP:
-(id) init
{
button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 sizeToFit];[button2 sizeToFit];[self sizeToFit];
item = i;
send.titleLabel.text = @"1";
feedback.titleLabel.text = @"2";
[self addSubview:button1];
[self addSubview:button2];
return self;
}
The cell:
PHP:
- (UITableViewCell* )tableView:(UITableView* )tableView cellForRowAtIndexPath:(NSIndexPath* )indexPath
{
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"123"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"123"];
}
cell.accessoryView = [[ItemCellAccessory alloc] init];
[cell.accessoryView retain];
return cell;
}