0
私はサーバーに接続しようとしていますが、サーバーがダウンしていると、接続でサーバーのダウンが発生し、エラーで失敗しました。 OKボタンをタップすると、後で行う最良の方法は何ですか。アラートが接続されたときに行うべきことはエラーで失敗しましたか?
私はサーバーに接続しようとしていますが、サーバーがダウンしていると、接続でサーバーのダウンが発生し、エラーで失敗しました。 OKボタンをタップすると、後で行う最良の方法は何ですか。アラートが接続されたときに行うべきことはエラーで失敗しましたか?
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.
参照してください:
輸入はUIAlertViewサブクラスの実装を設定します。 – iProgrammer