I have this alert view (disclaimer) that pop up when app finish launching. It works (my app is much slower now), but I also want to exit from the app if the user press no, thanks
. I think I should use clickedButtonAtIndex:.
1. Can somebody help me on this?
2. is viewDidLoad the best method to fire the alertView when the application start?
3. is there any reason why now my app take more time to start when I build and run it?
-(void)viewDidLoad {
UIAlertView *disclaimer = [[UIAlertView alloc] initWithTitle: @"DISCLAIMER" message:@"This Application is provided without any express or implied warranty. Errors or omissions in either the software or the data are not guaranteed against. The application is not intented to replace official documentation or operational procedure. In no event shal the developer be held liable for any direct or indirect damages arising from the use of this application" delegate:self cancelButtonTitle:@"No, thanks" otherButtonTitles:@"Accept", nil];
[disclaimer show];
[disclaimer release];
[super viewDidLoad];
}
Try this magic:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.cancelButtonIndex == buttonIndex){
// Do cancel
}
else{
// Do the real thing
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
// Do something
else
// Some code
}
or
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
// Do something
else
// Some code
}
Make sure your class conforms to the UIAlertViewDelegate
protocol.
And I dont think exiting from the app is a good approach though.You should only let the user close the application by pressing the home button. It's against the default behavior which the user expects every app to follow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With