zoukankan      html  css  js  c++  java
  • FormSheet式模态视图,点击模态视图外隐藏模态视图的方法

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    
        _tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleTapBehind:)];
        [_tapRecognizer setNumberOfTapsRequired:1];
        _tapRecognizer.cancelsTouchesInView = NO; 
        [self.view.window addGestureRecognizer:_tapRecognizer];
        [_tapRecognizer setDelegate:(id<UIGestureRecognizerDelegate>)self];
    }
    
    - (void)handleTapBehind:(UITapGestureRecognizer *)sender
    {
    
        if (sender.state == UIGestureRecognizerStateEnded) {
         
            CGPoint location = [sender locationInView:nil];      
    
            if (UIDevice currentDevice]systemVersion] floatValue] < 8.0) {
    
                if (UIInterfaceOrientationIsLandscape([UIApplicationsharedApplication].statusBarOrientation)) {
    
                    location = CGPointMake(location.y, location.x);
                }
            }       
    
            if (![self.view pointInside:[self.view convertPoint:location fromView:self.view.window] withEvent:nil]) {
            
                [self.view.window removeGestureRecognizer:sender];
                [self dismissViewControllerAnimated:YES completion:nil];
            }
        }
    }
    
    #pragma mark - UIGestureRecognizer Delegate
    
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
    {
        return YES;
    }
    
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer
    {
        return YES;
    }
    
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
        return YES;
    }
  • 相关阅读:
    mysql基础知识
    spring-jdbcTemplet 连接数据源(基础)
    mybatis-----的延迟加载-----缓存(一级缓存和二级缓存)
    第一次使用 idea,mybatis 获取 数据库 中的 数据 2017-9-14
    初识过滤器
    使用 Commens-FileUpload 组件实现文件上传
    简单 servlet 的使用
    QQ数据库管理-----mysql
    mysql 的使用
    json 解析
  • 原文地址:https://www.cnblogs.com/liuliuliu/p/4650950.html
Copyright © 2011-2022 走看看