【问题标题】:how to navigation using segue?如何使用 segue 导航?
【发布时间】:2014-07-12 12:11:03
【问题描述】:

我必须使用 segue 在按钮单击时导航到下一个屏幕,但条件是我调用 Web 服务,如果 Web 服务的结果是 SUCCESS,它应该导航,否则留在登录屏幕中。但是使用下面的代码它只是导航..

-(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:

结果 ----- :{ 响应 = 成功; 令牌 = 2e8c0ef66a5ac15b8f61da080c26d056218a6172; 错误代码 = 0; }

我该如何管理?我已将按钮与下一个视图关联。

【问题讨论】:

标签: ios iphone objective-c


【解决方案1】:

您必须在情节提要上设置一个 Segue Identity,然后使用这行代码来 Segue 到下一个视图控制器。

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

【讨论】:

  • 我确实创建了它。但我应该在哪里添加它委托?当我单击按钮时,它正在移动到下一个屏幕。
  • 如果你使用 performSegueWithIdentifier,我认为在 prepareForSegue 中你不应该有 pushViewController
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-13
  • 2016-12-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多