ios - How to change a Button action with Segmented Control -
i have button has action gives push view. goal make button open different views according selected segment. example: have button called "request" , have control segment 2 segments, called "pizza salt" , "sweet pizza." when selected, example, "pizza salt" in segment , click "request" button, want open view menu of "salt pizza.", , selected "sweet pizza" want button open view menu of "sweet pizza."
note: have 2 controllers ready views.
what code use?
my code:
- (ibaction)changebuttoncode:(id)sender { if (_firstsegmentsixthview.selectedsegmentindex == 0); } - (ibaction)pushtonextview:(id)sender { }
upon pressing request button:
if (_firstsegmentsixthview.selectedsegmentindex == 0) //salty { viewcontroller1 *vc1 = [[viewcontroller1 alloc] init]; [self.navigationcontroller pushviewcontroller:vc animated:yes]; } else if (_firstsegmentsixthview.selectedsegmentindex == 1) //sweet { viewcontroller2 *vc2 = [[viewcontroller2 alloc] init]; [self.navigationcontroller pushviewcontroller:vc2 animated:yes]; }
Comments
Post a Comment