2012-01-02 8 views
0

私はサーバーに接続しようとしていますが、サーバーがダウンしていると、接続でサーバーのダウンが発生し、エラーで失敗しました。 OKボタンをタップすると、後で行う最良の方法は何ですか。アラートが接続されたときに行うべきことはエラーで失敗しましたか?

+0

参照してください:

@interface ARReachabilityAlertView : UIAlertView <UIAlertViewDelegate> { } @end 

輸入はUIAlertViewサブクラスの実装を設定します。 – iProgrammer

答えて

0

UIAlertviewコントローラのデリゲートメソッドを使用できます。この質問のための

#import "ARReachabilityAlertView.h" 

@implementation ARReachabilityAlertView 

- (id)initWithFrame:(CGRect)frame { 
    if (self = [super initWithFrame:frame]) { 
    [self setTitle:@"Error"]; 
    [self setMessage:@"This application won't run without a network connection. Do you want to quit?"]; 
    [self addButtonWithTitle:@"Quit"]; 
    [self addButtonWithTitle:@"Continue"]; 
    [self setDelegate:self]; 
    } 
    return self; 
} 

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 0) 
    exit(0); // quit application if "Quit" is pressed; otherwise, do nothing 
} 

- (void) drawRect:(CGRect)rect { 
    [super drawRect:rect]; 
} 

- (void) dealloc { 
    [super dealloc]; 
} 

@end 

詳細は、[OK]ボタンをもう一度要求することができ、同じanswer here.

関連する問題