How can I dismiss UIAlertView ? This code doesn't work.
@property (nonatomic, retain) UIAlertView *activityAlertView;
- (void)viewDidLoad
{
self.activityAlertView = [[UIAlertView alloc] initWithTitle:@"Receiving data" message:@"\n\n"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil, nil];
[activityAlertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
}
-(void) myfunc
{
[self alertView:activityAlertView clickedButtonAtIndex:1];
}
The - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
method of the UIAlertView class does what you want. eg:
[myAlertView dismissWithClickedButtonIndex:-1 animated:YES];
Since you are using a delegate callback method of UIAlertView
, I think it is better you use the following code
[myAlertView dismissWithClickedButtonIndex:0 animated:YES];
if not then use the above suggested code
[myAlertView dismissWithClickedButtonIndex:-1 animated:YES];
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