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];