views:

130

answers:

1
-(void)setState:(id)sender
{
    UIButton* button = (UIButton*)sender;
    BOOL buttonBool = ([button state]==selected : YES ? NO);
    [sender setSelected:buttonBool++];

}

this is my idea, but i cant figure out the actual state of the button calling the funktion. any button, that calls this funktion, should be toggled between default and selected-state, so that it works like a switch. i just need to have own background-graphics, else i had used a switch.

so, can anyone please correct my idea ?

+1  A: 

Try this way:

-(void)setState:(id)sender
{
    UIButton* button = (UIButton*)sender;
    button.selected = !button.selected;
}
Vladimir
oh.. that was too simple !i think that this works, how i want it to work, thank you. i´ll try it tomorrow Message: You can accept an answer in 8 minutes so tomorrow i´m going to accept this
nico