Hi,
I have to add radio buttons in my iPhone application. For that I have got radio button image which is of round in shape. Can I add that image as a subview? and Can I add touchupinside event to UIImage?
Hi,
I have to add radio buttons in my iPhone application. For that I have got radio button image which is of round in shape. Can I add that image as a subview? and Can I add touchupinside event to UIImage?
You can try using the UIImageView class which just wraps a UIImage inside a UIView container. It supports the touchesBegan/Cancelled events which would be suitable I think.
You might also consider not using with a true radio button setup as you've described and instead going with a more iPhone-like approach--for instance, using a UITableView with cells corresponding to your radio selections and that toggle checked/unchecked on a touch. See the TouchCells example at the Apple iPhone dev site for an example.
iPhone apps do not have radio buttons. The "iPhone-like" way to do this is either by using a picker view or by having several rows in a grouped table view with a check accessory on the chosen row.
If for some reason you really, really feel the need to have radio buttons, use a UIButton with a button type of custom. Set the empty circle as the image for the "normal" control state and the filled circle as the image for the "selected" state.
You can also create a UIWebView, load into it HTML that uses radio buttons, and then using the UIWebView delegat methods, monitor the radio value.
It's kind of a hack, but in some cases it's exactly what's called for.