zoukankan      html  css  js  c++  java
  • 给UIWebView增加搜索栏

    在xib文件中拖入UIWebView。
    使用代码为UIWebView的滚动控件增加搜索栏:
    UISearchBar* searchBar=[[[UISearchBar alloc]initWithFrame:CGRectMake(0, -44, 320, 44)]autorelease];
        [self.browser.scrollView addSubview:searchBar];
        self.topBar=searchBar;
     [[self.browser scrollView] setContentInset:UIEdgeInsetsMake(44, 0, 0, 0)];
        self.browser.scrollView.scrollIndicatorInsets=UIEdgeInsetsMake(44, 0, 0, 0);
        [self.browser.scrollView setContentOffset:CGPointMake(0, -44)];//webview加载后会默认给滚动条设置滚动位置为0,0。
        self.browser.scrollView.delegate=self;//给滚动条加代理来调整滚动条指示控件的位置
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
        float y=scrollView.contentOffset.y;
        if (y>0) {//topbar不可见
             scrollView.scrollIndicatorInsets=UIEdgeInsetsMake(0, 0, 0, 0);
        }else{//topbar可见
            scrollView.scrollIndicatorInsets=UIEdgeInsetsMake(-y, 0, 0, 0);
        }
    }
    //删除UIWebView的阴影效果
     UIView* lastView = [[[[self.browser subviews] objectAtIndex:0] subviews] lastObject];
        for(UIView *wview in [[[self.browser subviews] objectAtIndex:0] subviews]) { 
            if([wview isKindOfClass:[UIImageView class]]) { 
                if (wview!=lastView) {//this is scroll indicator
                     wview.hidden = YES; 
                }
            }
        } 

    转http://qiufangzhou.blog.163.com/blog/static/506421802012347019554/ 

    UIWebView的Scroll事件的监测

    http://three20.pypt.lt/uiwebview-tap-scroll-detection 

  • 相关阅读:
    gitlab centos 安装配置运维笔记
    CentOS 7 升级内核 Kernel
    VMware 桥接模式 复制物理网络连接状态的作用
    diskpart setid value list
    怎样判断Windows的DPI大小?
    Camtasia Studio 6录制视频时鼠标闪烁的解决办法
    ssh的各个jar包作用
    MyEclipse优化技巧
    Struts详细用法
    Ajax的readyState和status属性
  • 原文地址:https://www.cnblogs.com/likwo/p/2475538.html
Copyright © 2011-2022 走看看