Can anybody tell me the code to make radio button and checkbox button in iphone. Thanks in advance.
3 Answers
Unless you really want to provide the users with a non-standard experience and invent your own controls (which are likely to not be so fine-tuned as those provided out-of-the-box), i would go with UISwitch instead of checkbox and UIPickerView instead of a radiobutton(s)

- 18,317
- 9
- 53
- 64
@Nitin in these cases you have to use the images in UIImageView
for checked or unchecked....basically they are images or one more procedure is to use the custom UIButton
and give them images accordingly to situation

- 3,950
- 1
- 19
- 18
-
1
-
1@DarkDust i had done the same procedure in my app...that's why i suggest – Sudhanshu Jan 20 '11 at 08:14
You have to do it manually by using UIButtons:
Checkbox: create two images, assign one via setImage:forState:
with state UIControlStateNormal
, the other with state UIControlStateSelected
. Then you can toggle the images simply by setting the button's selected
property to NO or YES.
Radiobox: same as with checkbox, but you have to keep track of the other radioboxes (e.g. via an array) and set foo.selected = NO
for all the not-selected checkboxes.

- 90,870
- 19
- 190
- 224