| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // PopupNavigationController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 14-7-7.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "PopupNavigationController.h"
- #import "AppDelegate.h"
- @interface PopupNavigationController ()
- @end
- @implementation PopupNavigationController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handletapPressGesture:)];
- AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- [app.window addGestureRecognizer:tapGesture];
- tapGesture.delegate = self;
- self.tapGesture = tapGesture;
- }
- -(void)viewDidDisappear:(BOOL)animated
- {
- [super viewDidDisappear:animated];
- AppDelegate *app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [app.window removeGestureRecognizer:self.tapGesture];
-
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
- {
- // DebugLog(NSStringFromClass([touch.view class]));
- if ([NSStringFromClass([touch.view class]) isEqualToString:@"UIDimmingView"]) {//如果当前是tableView
- //做自己想做的事
- return YES;
- }
- return NO;
- }
- -(void)handletapPressGesture:(UITapGestureRecognizer*)sender{
- CGPoint point = [sender locationInView:self.view];
- if (point.x<self.view.frame.origin.x || point.x >self.view.frame.origin.x+self.view.frame.size.width||point.y<self.view.frame.origin.y||point.y>self.view.frame.origin.y+self.view.frame.size.height) {
- [self dismissViewControllerAnimated:YES
- completion:^{
- //一定要移除手势 否则下次 没有子视图的时候 点击 会崩溃拉
- AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- [app.window removeGestureRecognizer:sender];
- }];
- }
-
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|