【发布时间】:2010-11-18 10:16:58
【问题描述】:
我知道 xcode 没有单选按钮
所以我尝试添加一个自定义按钮并使其像单选按钮一样操作
这是我使用的图像
这是我设置到单元格的代码
UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];
[but setImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
[but setImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
[but setFrame:CGRectMake(0, 0, 44, 44)];
[but addTarget:self action:@selector(radioButton:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView= but;
而这就是我要问的问题是
我怎样才能在- (IBAction)radioButton:(UIButton *)button中给一个空白
控制两行中的两个单选按钮
如果第 1 行单选按钮被选中是 YES
第 2 行中的 btn 将是 btn.state=NO 并且不会响应
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
会是这样的图片
- (IBAction)radioButton:(UIButton *)button中如何设置if条件
这张图片是假的...我只在单元格中添加了按钮...并更改了文本颜色
非常感谢所有堆栈溢出的朋友~
【问题讨论】:
-
你知道TableView可以原生管理单元格检查吗:developer.apple.com/library/ios/#documentation/UserExperience/…
-
我知道...但我的老板坚持这样看起来更好...所以你知道...
标签: iphone cocoa-touch uitableview radio-button