I installed UIAlertView in the AppDelegate.m file.
But when I select the button on the warning screen.
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
did not work.
I installed UIAlertViewDelegate in the AppDelegate.h file.
and my 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;
case 1:
NSLog(@"set!");
NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];
[[UIApplication sharedApplication] openURL:url];
break;
}
}
But
-(void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
did not introduce this method.
Does anyone know what happened? thank.
source
share