ios - Have one button go to a different view and enable button -
i working on app have multiple buttons on 1 page click on go different view. thing user click on them in specific order. basically, have buttons locked except 1 , each time click on button enabled, unlocks new one.
thanks.
you can via tag
when creating view @ time put firstbutton
in enabled
mode.
onclick
event on every uibutton
can enabled
next one.
for example
i created view
4 uibutton
, given tag 1,2,3,4
@ viewload
uibutton
tag
1 enabled
for 4 uibutton
have created common action
method follow enabled
next uibutton
next tag
-(void)viewwillappear:(bool)animated { [super viewwillappear:animated]; if([[nsuserdefaults standarduserdefaults] valueforkey:@"lastenablebutton"]){ uibutton * btntemp = (uibutton *) [self.view viewwithtag:[[[nsuserdefaults standarduserdefaults]valueforkey:@"lastenablebutton"] intvalue]]; [btntemp setenabled:yes]; nslog(@"if want enable button enabled make loop nsuserdefaults value starting value"); } } - (ibaction)btn_click : (id)sender { uibutton * btntemp = (uibutton *) [self.view viewwithtag:([sender tag] + 1)]; if(btntemp) { if([btntemp iskindofclass:[uibutton class]]) { [btntemp setenabled:yes]; [[nsuserdefaults standarduserdefaults]setvalue:[nsnumber numberwithint:([sender tag] + 1)] forkey:@"lastenablebutton"]; [[nsuserdefaults standarduserdefaults]synchronize]; } } }
Comments
Post a Comment