Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c xcode中单选按钮的问题_Objective C_Radio Button_Xcode4.5 - Fatal编程技术网

Objective c xcode中单选按钮的问题

Objective c xcode中单选按钮的问题,objective-c,radio-button,xcode4.5,Objective C,Radio Button,Xcode4.5,我对xcode中ios中的单选按钮有问题。我想通过两个按钮(按钮上的图像)来实现这一点。我如何使这两个按钮像单选按钮一样?有什么帮助吗?您错过了addSubview,我是为您这样做的:)Thnx代表您的答案..但我关心的是如何管理更改两个按钮之间的图像基本上是控件…因为当一个按钮处于uicontrol状态时,其他按钮将处于选中模式,反之亦然..Thnx处于Advacnce使用命令:[btn setSelected:NO]在所有其他btn上循环怎么样;?所以基本上我们需要设置一个bool值来确定按

我对xcode中ios中的单选按钮有问题。我想通过两个按钮(按钮上的图像)来实现这一点。我如何使这两个按钮像单选按钮一样?有什么帮助吗?

您错过了addSubview,我是为您这样做的:)Thnx代表您的答案..但我关心的是如何管理更改两个按钮之间的图像基本上是控件…因为当一个按钮处于uicontrol状态时,其他按钮将处于选中模式,反之亦然..Thnx处于Advacnce使用命令:[btn setSelected:NO]在所有其他btn上循环怎么样;?所以基本上我们需要设置一个bool值来确定按下和释放哪个按钮。你想用“两个单选按钮”做什么,你能更具体一点吗?
UIButton *radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[radioBtn setImage:[UIImage imageNamed:@"radioOff.png"] forState:UIControlStateNormal];
[radioBtn setImage:[UIImage imageNamed:@"radioOn.png"] forState:UIControlStateSelected];
[radioBtn setBackgroundColor:[UIColor clearColor]];
[radioBtn addTarget:self action:@selector(myfunc) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:radioBtn];