1

I have to navigate to next screen on button click using segue,but the condition is i call a web service ,if the result from web service is SUCCESS it should navigate else stay in the loginscreen. But using the below code it simply navigates ..

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"loginbutton"])
    {
        [self.sharedController setLoginDetailsDyanamic1:_strUsername.text password:_strPassword.text delegate:self];

        if ([[dictresult objectForKey:@"Response"]  isEqual: @"Success"])
        {
            DashBoardViewController *obj = [[DashBoardViewController alloc]init];
            [self.navigationController pushViewController:obj animated:YES];
       }
    }
}
//delegates
-(void)controllerDidFinishLoadingWithResult:(id)result;
{
    dictresult = result;
    NSLog(@" result ----- :%@",dictresult);
    NSLog(@" result of key----- :%@",[dictresult objectForKey:@"Response"]);
//    if ([[result objectForKey:@"Response"]  isEqual: @"Success"])
//    {
//        DashBoardViewController *obj = [[DashBoardViewController alloc]init];
//        [self.navigationController pushViewController:obj animated:YES];
//        
//    }

}
-(void)controllerDidFailLoadingWithError:(NSError*)error;
{}
 The result that i get in -(void)controllerDidFinishLoadingWithResult:(id)result is:

result ----- :{ Response = Success; Token = 2e8c0ef66a5ac15b8f61da080c26d056218a6172; errorCode = 0; }

How do i manage this? I have wired my button with the next view.

user2798258
  • 171
  • 1
  • 4
  • 13
  • choice 1 : http://stackoverflow.com/questions/20715462/receiver-viewcontroller-has-no-segue-with-identifier-addsegue/20715545#20715545 choice 2: http://stackoverflow.com/questions/23102978/swrevealviewcontroller-without-using-navigationcontroller/23105142#23105142 – Anbu.Karthik May 23 '14 at 08:13

1 Answers1

1

You have to set a Segue Identity on your storyboard then use this line of code to Segue to the next view controller.

    [self performSegueWithIdentifier:@"SegueIdentity" sender:self];

enter image description here

Ricky
  • 10,485
  • 6
  • 36
  • 49
  • i did create it. but where should i add it in delegate ? it is moving to next screen as i click button. – user2798258 May 23 '14 at 09:20
  • I think inside prepareForSegue you should not have pushViewController if you are using performSegueWithIdentifier – Ricky May 23 '14 at 09:26