objective c - Xcode Help using if statement to hide buttons -
i've got 3 buttons - when button 1 'grassleft' pressed want hide it/make fade out (and push next segue), after buttons 2 , 3 have been pressed , have disappeared first. don't want grassleft method push segue until grassmiddle , grassright have disappeared. don't think i'm using if statement properly. code:
- (ibaction)grassleft:(id)sender { if ((grassrightbutton.hidden == yes)) { grassleftbutton.alpha = 0; } if ((grassmiddlebutton.hidden == yes)) { grassleftbutton.alpha = 0; } else { [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.grassleftbutton.alpha = 0; } completion:^(bool finished) { self.grassleftbutton.alpha = 0.0; [grassleftshakes invalidate]; }]; } double delayinseconds = 1; dispatch_time_t poptime = dispatch_time(dispatch_time_now, (int64_t)(delayinseconds * nsec_per_sec)); dispatch_after(poptime, dispatch_get_main_queue(), ^(void){ [self performseguewithidentifier:@"gotoyakenclosure" sender:self]; }); } - (ibaction)grassmiddle:(id)sender { [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.grassmiddlebutton.alpha = 0; } completion:^(bool finished) { self.grassmiddlebutton.alpha = 0.0; [grassmiddleshakes invalidate]; grassmiddlebutton.hidden = yes; }]; } - (ibaction)grassright:(id)sender { [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.grassrightbutton.alpha = 0; } completion:^(bool finished) { self.grassrightbutton.alpha = 0.0; [grassrightshakes invalidate]; grassrightbutton.hidden = yes; }]; }
take 2 int variable middleflag , rightflag
now in grassrightbutton's action method assign rightflag = 1 , hide grassrightbutton
and in grassmiddlebutton's action method assign middleflag = 1 , hide grassmiddlebutton
now, in grassleft method
- (ibaction)grassleft:(id)sender { if (rightflag == 1 && middleflag == 1 ) { grassleftbutton.alpha = 0; // if want segue performed if 2 , 3 button pressed put code here perform segue. } else { [uiview animatewithduration:0.3 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.grassleftbutton.alpha = 0; } completion:^(bool finished) { button.alpha = 0.0; [grassleftshakes invalidate]; double delayinseconds = 1; dispatch_time_t poptime = dispatch_time(dispatch_time_now, (int64_t)(delayinseconds * nsec_per_sec)); dispatch_after(poptime, dispatch_get_main_queue(), ^(void){ [self performseguewithidentifier:@"gotoyakenclosure" sender:self]; }); }]; } }
Comments
Post a Comment