objective c - Switch views from alert view options in xcode -
i want move other views created in storyboard through alert view menu buttons displayed in home page. alert view gives list of buttons containing different views.
how can move views.
i using
-(void) alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if (buttonindex == 1){ } if (buttonindex ==2) { } if(buttonindex == 3){ } }
first need instance of storyboard.
instantiate viewcontrollers using storyboard.
push onto navigation stack usual.
-(void) alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { uistoryboard *storyboard = [uistoryboard storyboardwithname:@"storyboard_name" bundle:nil]; if (buttonindex == 1) { viewcontroller1 *vc1 = (viewcontroller1 *)[storyboard instantiateviewcontrollerwithidentifier:@"view1"]; [self.navigationcontroller pushviewcontroller:vc1]; } if (buttonindex ==2) { viewcontroller2 *vc2 = (viewcontroller1 *)[storyboard instantiateviewcontrollerwithidentifier:@"view2"]; [self.navigationcontroller pushviewcontroller:vc2]; } if(buttonindex == 3) { } }
Comments
Post a Comment