0

送信ボタンのあるユーザー ログイン ページがあります。ログインに成功したら、次のビューに移動します。 .これは正常に動作しています。つまり、次のように NSXMLParser を使用して値を取得できます。

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    if (elementFound) {
        soapResults = [string boolValue];
        //NSLog(@"soapResultss = %@",soapResults);

    }
    if (soapResults)
    {
        x = 1; // x is 1 if username and password are correct.
    }
    else
    {
        x = 0;//x is 0 if username and password are incorrect
    }
}

(成功した場合)「送信ボタンのクリック」メソッドで次のビューを呼び出そうとしています:

if(x==0)
    {

    }
    else if(x==1)
    {
        [self.navigationController pushViewController:self.viewController animated:YES];
    }

しかし、問題は、コントロールが「送信ボタンのクリック」、つまり「else if」の部分に戻らないことです。そして、これは正しい方法ではないと思います。これを行う正しい方法は何ですか? ? 提案してください。ありがとう。

4

2 に答える 2

0

ビューコントローラオブジェクトでselfを使用している理由をこのコード行で確認します

 [self.navigationController pushViewController:self.viewController animated:YES];

このコード行を使用します(ViewControllerのオブジェクト)

 [self.navigationController pushViewController:viewController animated:YES];
于 2013-02-13T12:41:38.033 に答える
-1

この場合、TRUE/FALSE を使用するだけでは機能しないようです。

enumdataType を試すと効果的です

.h ファイル内

enum {
    kReceivingSoapData,
    kReceivedIncorrectData,
    kReceivedCorrectData

}receivedSoapResult;

@interface ViewController : UIViewController{
.....
}

使用される方法で

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    if (elementFound) {
        soapResults = [string boolValue];
        //NSLog(@"soapResultss = %@",soapResults);

    }
    if (soapResults)
    {
    receivedSoapResult = kReceivedCorrectData;
    }
    else
    {
      receivedSoapResult = kReceivedIncorrectData;;
    }
}

アクションメソッドで

if(receivedSoapResult == kReceivedIncorrectData)
    {
// incorrect uName and password received
    }
    else if(receivedSoapResult == kReceivedCorrectData)
    {
      //correct password received
        [self.navigationController pushViewController:self.viewController animated:YES];
    }
else{
// still receiving data

}
于 2013-02-13T13:09:56.410 に答える