点击UIAlertView弹窗外空白收回弹窗,UIAlertView是添加在[UIApplication sharedApplication].keyWindow上的
alert = [[UIAlertView alloc]initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"马上升级" otherButtonTitles:title, nil];
[alert show];
UITapGestureRecognizer *recognizerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)];
[recognizerTap setNumberOfTapsRequired:1];
recognizerTap.cancelsTouchesInView = NO;
[[UIApplication sharedApplication].keyWindow addGestureRecognizer:recognizerTap];
- (void)handleTapBehind:(UITapGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateEnded)
{
CGPoint location = [sender locationInView:nil];
if (![alert pointInside:[alert convertPoint:location fromView:alert.window] withEvent:nil])
{
[alert.window removeGestureRecognizer:sender];
[alert dismissWithClickedButtonIndex:0 animated:YES];
isAlertShoiw = NO;
}
}
}