0

最初のシーンがログイン画面であるアプリケーションがあります。ログイン ボタンを押すと、ユーザー名とパスワードが正しければ、次のシーンが呼び出されます。それ以外の場合は、アラートが表示されます。しかし、条件付きで次のシーンを取得する方法がわかりません。

if ([jsonDict valueForKey:@"success"] && [jsonDict valueForKey:@"redirect"]) {

                    NSLog(@"%@", [jsonDict valueForKey:@"success"]);
                    NSLog(@"%@", [jsonDict valueForKey:@"redirect"]);
                    NSString *redirect = [jsonDict valueForKey:@"redirect"];
                    [self performSegueWithIdentifier:@"next" sender:self];
                }
                else {
                    NSArray *jsonArray = [jsonDict valueForKey:@"errors"];
                    NSString *err = [jsonArray objectAtIndex:0];
                    NSLog(@"%@", err);
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Credentials!" message:err delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
                    [alert show];
                }
4

2 に答える 2

0

ストーリーボードの次のビューコントローラーへのセグエを設定し、そのセグエに一意の識別子を与えます。次に、ユーザー名とパスワードに問題がなければ、電話するだけです

[self performSegueWithIdentifier:@"yourSegueIdentifier" sender:self];
于 2013-06-12T12:13:34.517 に答える
0

以下のコードを使用します。

- (void)validateLogin{
//code to check username and password are correct
if(correct){
[self performSegueWithIdentifier:@"SignInToNextScreen" sender:self];
}else{
 UIAlertView *myalert = [[UIAlertView alloc]initWithTitle:@"Login Failed" message:@"Invalid Username/Password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];   
   }
 }

// SignInToNextScreenは、手動でトリガーされたセグエのセグエ識別子です。

添付のスクリーンショットをご覧ください ここに画像の説明を入力

于 2013-06-12T12:15:41.953 に答える