I have been googling this problem for almost a whole day now, without getting any closer to a solution, so i would like to ask you guys.. :)
I'm working on an iOS app, which should connect to a mbed over WiFi and give the user a dialog if it connects and if it doesn't and if not, then give the user the possibility to retry. My problem is now that i have implemented the connecting method in appdelegate.m and it is from here I would like to show the alerts..
The alerts it self works fine, but I have problems detecting when a button is pressed, the clickedButtonAtIndex is not being called.
I have added the UIAlertViewDelegate in the appdelegate.h, like so:
@interface AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate, UIAlertViewDelegate>
and have set the delegate to self, in the alertview, like so:
alert_NOT = [[UIAlertView alloc] initWithTitle:@"Not connected!" message:message_to_user delegate:self cancelButtonTitle:@"Try again" otherButtonTitles: nil];
[alert_NOT show];
[alert_NOT release]
and the clickedButtonAtIndex looks like
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"test");
}
So I would love to see the word "test" in the log when a button is pressed in the alertview, but nothing happens.
Update: Tried implementing it in my "FirstViewController.m" and there it works :S but I would very much like to have it in the appdelegate.m if possible..