zoukankan      html  css  js  c++  java
  • UIWebView支持点击事件,实现全屏功能

    在UIWebView上加手势

    View Code
    1 UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self
    2                                                                                 action:@selector(handleSingleTap:)];
    3     [self.view addGestureRecognizer:singleTap];
    4     singleTap.delegate = self;
    5     singleTap.cancelsTouchesInView = NO;
    6     [singleTap release];

    对手势动作进行处理实现全屏

    View Code
    - (void)handleSingleTap:(id)sender
    {
        if (!isFullScreen) {
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
            [self.navigationController setNavigationBarHidden:YES animated:YES];
            [self.navigationController setToolbarHidden:YES animated:YES];
            isFullScreen = YES;
        } else {
            [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
            [self.navigationController setNavigationBarHidden:NO animated:YES];
            [self.navigationController setToolbarHidden:NO animated:YES];
            isFullScreen = NO;
        }
    }

    关键是需要加上手势的代理

    View Code
    // called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
    // return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
    //
    // note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
    
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }

    因为UIWebView上的touches,move事件会被其scrollView捕获,此代理允许了两个事件可以同时发生。

    当然也可以使用JS实现在UIWebView上的点击事件~

  • 相关阅读:
    golang 常见疑惑总结
    golang 详解defer
    golang调试工具Delve
    ACE的源码划分
    通过#define连接字符串的特殊方法[转]
    转:extern "C"的用法解析
    转:3d max 2013 安装教程,凭着一种互联网精神提供给广大朋友
    转:Bullet物理引擎不完全指南(Bullet Physics Engine not complete Guide)
    转:折腾一晚上Bullet及Ogre相关工具的成果 -- 3Ds Max,Maya, blender, GameKit
    转:CMake快速入门教程-实战
  • 原文地址:https://www.cnblogs.com/horo/p/2954094.html
Copyright © 2011-2022 走看看