Ios 根据条件导航到不同视图控制器的按钮

Ios 根据条件导航到不同视图控制器的按钮,ios,iphone,objective-c,segue,xcode-storyboard,Ios,Iphone,Objective C,Segue,Xcode Storyboard,我是IOS新手。我正在IOS中制作一个登录视图控制器,其中一个按钮是登录。我有两个可能的视图控制器,当用户单击登录按钮时可能会显示。我正在使用故事板,但我只能为一个按钮分配一个序列。我不知道如何执行该条件,因为我似乎没有100%的控制权。 这是我的密码: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *stringreponse=[[NSString alloc] initWithD

我是IOS新手。我正在IOS中制作一个登录视图控制器,其中一个按钮是登录。我有两个可能的
视图控制器
,当用户单击登录按钮时可能会显示。我正在使用故事板,但我只能为一个按钮分配一个序列。我不知道如何执行该条件,因为我似乎没有100%的控制权。 这是我的密码:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSString *stringreponse=[[NSString alloc] initWithData:_responseData encoding:NSUTF8StringEncoding];
   // NSLog(@"Split response %@", [splitresponse objectAtIndex:0]);
    if([stringreponse isEqualToString:@"0"])
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Wrong username or password" message:@"Wrong username or password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }
    else
    {
        NSArray *splitresponse=[stringreponse componentsSeparatedByString:@"#"];
        if([[splitresponse objectAtIndex:0] isEqualToString:@"Parent"])
        {
            if([[splitresponse objectAtIndex:2] isEqualToString:@"yes"])
            {
                //seguechoice=@"showParentRegistration";
               //[self performSegueWithIdentifier:@"showParentRegistration" sender:self ];
            }else{
                //seguechoice=@"showSohoDashboard";
            }
        }
    }
}

您可以为一个UI控件分配一个序列,但也可以为ViewController分配多个序列。只需将它们全部添加到viewController中,为每个添加一个不同的id,然后调用这些id的

if([[splitresponse objectAtIndex:2] isEqualToString:@"yes"])
{
    [self performSegueWithIdentifier:@"showParentRegistration" sender:self ];
}
else
{
    [self performSegueWithIdentifier:@"showSohoDashboard" sender:self ];
}

在序列图像板中创建从源视图控制器到目标视图控制器(非按钮)的2个连接。插入两个不同的标识符,当按下按钮时,根据条件执行条件并运行序列:

if(CONDITION TO RUN SEGUE !)
{
   [self performSegueWithIdentifier:@"SEGUEIDENTIFIER1" sender:self ];
}else {
    [self performSegueWithIdentifier:@"SEGUEIDENTIFIER2" sender:self ];
}

请打印
StringResponse
result。通过viewController将segue分配给其他两个viewController,并为这两个控制器中的每一个指定两个不同的标识符,然后执行您想要的操作。Thanx刚刚算出了Thanx Simon,也刚刚算出了。