Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yaboy10holla

macrumors newbie
Original poster
Feb 19, 2011
17
0
Hi guys,

I am trying to create a button that toggles between two states, that does on thing on the first press, and "un-does it" on the second press. Would anyone like to point me in the right direction? Ive thought of maybe creating a counter that tracks the clicks and then basing an action on whether the count is odd or even, but there has to be an easier and better way then that im sure? thanks!
 
One way to do this is to make two buttons and stack them on top of one another. Then make two methods:
Code:
-(IBAction)press1{
    //do stuff
    button1.hidden=YES;
    button2.hidden=NO;
}

-(IBAction)press2{
    //do stuff
    button1.hidden=NO;
    button2.hidden=YES;
}

Nick
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.