-1

AlertView に問題があります。を使用しようとしていますがUIAlertView、[OK] をクリックすると前の画面に戻りますが、何のアドバイスも得られないようです。

if (xGPSCoordinate==0 && yGPSCoordinate == 0) {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" 
                                                    message:@"Failed to load the to get your current location"
                                                   delegate:self 
                                          cancelButtonTitle:@"Ok" 
                                          otherButtonTitles:nil, nil];
    [alert show];
    [alert release];

    return;
    [self.navigationController popViewControllerAnimated:YES];
} 

また

if (xGPSCoordinate==0 && yGPSCoordinate == 0) {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"iPoly" 
                                                    message:@"Failed to load the to get your current location"
                                                   delegate:self 
                                          cancelButtonTitle:@"Ok" 
                                          otherButtonTitles:nil, nil];
    [alert show];
    [alert release];
    [self.navigationController popViewControllerAnimated:YES];
    return;

}   

どちらも機能しません

4

3 に答える 3

3

この目的のために、UIAlertViewのデリゲートメソッドを使用する必要があります。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

最初にこれをあなたの@interface <UIAlertViewDelegate>

次に、デリゲートを設定しself.yourAlertView.delegate=selfます。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

       if(buttonIndex==0)//first button which should be the OK button
       {

              [self.navigationController popViewControllerAnimated:YES];

       }

 }
于 2012-08-16T08:55:17.287 に答える
1

UIAlertView のデリゲート メソッドを使用します。iNoob の回答を参照してください。「return;」の後に何か書いても意味がありません。以下のコードとしてのステートメント「return;」ステートメントは決して実行されません。

UIAlertView デリゲートの詳細については、Apple 開発者のリンクを参照してくださいhttp://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html

またはアラート ビューに関する簡単なチュートリアル http://mobile.tutsplus.com/tutorials/iphone/uialertview/

于 2012-08-16T09:04:32.867 に答える
0

UIAlerView Delegate メソッドを実装するだけです。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{}

ここに、Pop to previous Controller のコードを記述します。クリックしたボタンのインデックスを作成し、それに基づいて使用できます。UIAlertViewDelegate を Interface に適合させないでください。

于 2012-08-16T09:00:25.893 に答える