开发者

Using custom UITableViewCell's accessory view to show two items

I've been looking for this for a while, but haven't found an answer (blame poor googling skills). I have a custom UITableViewCell class which, currently, consists of a custom UISwitch and a UILabel. I want to add a button that's only visible (And active) when the switch is set to "Yes". Right now I add the switch to the accessoryView, and leave it. However, the accessory view doesn't really have subviews, as far as I can tell, so here's my question:

Should I just create a UIView that has a button and a switch, size it to fit the cell's accessory view (or will it auto-size itself?), and put that in as the cell's accessory view? And is this typically the way that it's gone about?

Or is there开发者_开发问答 a solution that I'm missing?

Thanks.


Here is an example:

UIButton* btdel = [[UIButton alloc] init]; 
btdel.tag = indexPath.row; 
//[btdel setTitle:@"Delete Event" forState:UIControlStateNormal];
[btdel setBackgroundImage:[UIImage imageNamed:@"ButtonRemove.png"] forState:UIControlStateNormal];
[btdel addTarget:self action:@selector(deleteEvent:) forControlEvents:UIControlEventTouchUpInside];
// bt.titleLabel.frame = CGRectMake(0, 0, 95,24); 
btdel.frame = CGRectMake(110, 0, 30,30); 
[headerView addSubview:btdel];
[btdel release];

UIButton* bt = [[UIButton alloc] init]; 
bt.tag = indexPath.row;  
[bt setTitle:@"Select a Dress" forState:UIControlStateNormal];
[bt setBackgroundImage:[UIImage imageNamed:@"findDress.png"] forState:UIControlStateNormal];
[bt addTarget:self action:@selector(showDresses:) forControlEvents:UIControlEventTouchUpInside];

bt.font=[UIFont systemFontOfSize:(CGFloat ) 13];

// bt.titleLabel.frame = CGRectMake(0, 0, 95,24); 
bt.frame = CGRectMake(0, 3, 95,24);

[headerView addSubview:bt];
cell.accessoryView = headerView;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜