2013-01-11 69 views
0

我在xcode中的ios中的單選按鈕有問題。我想在兩個按鈕(按鈕上的圖像)的幫助下實現此操作。如何將兩個按鈕單選按鈕?有什麼幫助?xcode中的單選按鈕的問題

+0

你想要做什麼'兩個單選按鈕',你可以更具體嗎? – TheWhiteRabbit

回答

0
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]; 
+0

你錯過了addSubview,我爲你做了... :) –

+0

thnx爲你的答案..但我的關注是如何設法改變兩個按鈕之間的圖像基本上控制...因爲當一個按鈕在uicontrolstate正常其他將在選定的模式,反之亦然.. thnx在advacnce – user1667831

+0

如何在所有其他btns與命令循環:[btn setSelected:NO];? – alex