AppDelegate.m ファイルに UIAlertView を設定しました。
しかし、アラートビューのボタンを選択すると。
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
動作していませんでした。
AppDelegate.h ファイルに UIAlertViewDelegate を設定しました。
と私の AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
NSString *remoteHostName = REACHABILITY_HOST;
_hostReachability = [Reachability reachabilityWithHostName:remoteHostName];
[_hostReachability startNotifier];
return YES;
}
- (void) reachabilityChanged:(NSNotification *)note
{
if( [Reachability isExistNetwork] == NotReachable)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"my message" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:@"set",nil];
[alertView show];
}
}
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
NSLog(@"ok!");
break;
// set
case 1:
NSLog(@"set!");
NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];
[[UIApplication sharedApplication] openURL:url];
break;
}
}
しかし
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
このメソッドに入っていませんでした。
何が起こったのか知っている人はいますか?ありがとう。