In ios 7.0 I just want to close that action sheet whenever the user presses outside of that popover.I am showing that action sheet on button click and using this code trying to get some tap gesture on actionsheet.window
-(IBAction)buttonClicked:(id)sender{
NSLog(@"button clicked");
NSLog(@"action sheet ");
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Rename",@"Delete",@"Cancel" ,nil];
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setBackgroundColor:[UIColor whiteColor]];
[button setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
}
}
// [actionSheet setBackgroundColor:[UIColor whiteColor]];
[actionSheet showInView:self.view];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)];
tap.cancelsTouchesInView = NO;
[actionSheet.window addGestureRecognizer:tap];
[actionSheet.window addGestureRecognizer:tap];
}
-(void)tapOut:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"in tap out");
CGPoint p = [gestureRecognizer locationInView:actionSheet];
if (p.y < 0) {
NSLog(@" p.y < 0 ");
}
}
But am not getting this tap gesture.Please help me in solving this.