Can't deselect DLRadioButton radio button - swift

I'm using DLRadioButton but I can't deselect a radio button.
Here I want the user to check either or both of the buttons, but once selected they can't be deselected.

Make radio button using UIButton
and set selected and default image for UIButtons
Not get actions of both the radio buttons and on click of one change the state of buttons

There's an option to config it without an outlet, without switching to a UIButton.
If you do want to toggle, you can actually set isMultipleSelectionEnabled property on the button/checkbox to true.

Related

UIButton's Selected State not working in iOS7

I am using Xcode 5's storyboarding to create an application, iOS SDK 7.0.
I dragged a button to the View. I want my button to display "A" by Default. Below are the button properties:
Type: System, State Config: Default, Title: Plain
I want my button to display "B" in selected state. So, the button properties that changed:
State Config: Selected
In the Button's Attribute inspector, under the Control, there is a property called Selected.
If I check Selected, instead of displaying "B", it just highlights like a marker over A, i.e, no character is seen.
I ran it in XCODE. WHen the button is not selected "A" is displayed as expected but when I select the button, instead of displaying B, the text portion of the button is highlighted with light blue color. Also, I never selected the Highlighted Content under the Control.
How can this be resolved, so that I can display the state correctly?
For anyone who set the button title by code, I found on iOS 7.1, you need to explicitly set title for various button states, while on iOS 7.0, setting title for UIControlStateNormal will also do for other button states.
// works on 7.0
[self.ibActionButton setTitle:NSLocalizedString(#"Register", nil) forState:UIControlStateNormal];
// works on 7.1
[self.ibActionButton setTitle:NSLocalizedString(#"Register", nil) forState:UIControlStateNormal|UIControlStateDisabled];
You need to set the title of the button to 'B' while you have State Config set to Selected in your storyboard. Then you need to connect an action to the button's Touch Up Inside event. Inside of that action, toggle the button's selected property.
When you check 'Selected' under the Attributes Inspector, you are just setting the button's initial selected state to YES. XCode also shows you what the button would look like in that state.
I found that this is a bug in XCODE 5, that is, when we check the selected property under Control for the button, it doesn't show the selected state on the Button. It works in the simulator we run the application. We would need to do a target-action for the button and toggle the selected state as below
- (IBAction)flipButton:(UIButton *)sender {
sender.selected=!sender.isSelected;
}

Want to see the image only in iPhone

I have a button connected to an action.
When I set the background image on that button, the result is not visually appealing. I want just to see the image not the button but I want the ibaction functionality of that button.
Please help
You need a button with type UIButtonTypeCustom (this will stop the default button appearance from drawing). You can do this in interface builder or in code (although you can't change it once the button is initialized).

UIButton states

I am making multiple custom buttons that look much like this:
It is a simple button with either the green or gray in the "indicator view". What I need some explanation for is: In interfacebuilder there are four states a button can have; Normal, Highlighted, Selected and Disabled. When I provide images for everything except disabled I thought that normal would be when no touches were made on the button, highlighted is while you hold your finger on it and selected would be when after you release finger.
However I do not think thats right now. I use the touch-up-inside event. Is it correct that I need to set the selected/highlighted etc property on the button?
Thank you for your time.
You might want to set to selected and not highlighted.
Highlight is darkening the button for a fraction when touching the UIButton. UIButton can modify your image automaticaly so usually you don't need to provide a highlight image.
Disabled is when it is disabled.
Selected is when it is selected. You can invert the select flag on touch up inside event to make a state button.
[button setSelected:![button isSelected]];
Yes, you need to respond to the touch up inside by setting the button to highlighted.
Btw, it's "disabled" not deselected, but it doesn't sound like you need that state.

UIActionSheet Customization

Can we change the order in which the destructive button and Other buttons appear in an UIActionSheet. By default the destructive button (red colored) appears above other buttons, in my app I would like the other buttons to appear above the destructive button.
No Problem.
Just alloc and init a new UIActionSheet instance and add the buttons in your order (one after another) using –addButtonWithTitle:. This method returns you the index at which the button has been added to. You can then set the Index of the destructive button via -setDestructiveButtonIndex:.
You can make any button in the UIActionSheet as destruction button by using the UIActionSheet property destructiveButtonIndex like,
actionSheet.destructiveButtonIndex = 1;

uibutton property to avoid highlights

At the time of click a button it's highlighted. While click the button i want to avoid the highlighting of button.
In my Application background image for the button is square shape if i'm click the button it shows square outline of the button.but my button is customtype only....
Please help me out to solve this....
Thank you
Renya
Try setting button's adjustsImageWhenHighlighted property to NO
set adjustsImageWhenHighlighted property to YES...
it will avoid the highlight of UIButton
If you are creating button using Interface Builder..
Inside the button Attribute Inspector ..
On the top .. there is drop down box.. which has different states of the button
like Default, Highlighted, Selected etc.. you can set Button's behavior here..
Did you try adding :
[ homebut setHighlighted:NO ];
?