h5打包app后的问题

1、苹果页面超出隐藏造成卡顿

  解决方式  overflow:auto; -webkit-overflow-scrolling: touch; /* ios5+ */

2、h5打包后在ios下内容与状态栏重叠问题:

  1:知道设备的类型:

    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    上面的isAndroid和isios返回的都是boolean类型的值。
 

  2:当设备是ios时,添加一个给body加一个类名:

    if(isiOS){
       $("body").addClass("uh_ios7");
    }
 

  css文件下加样式:

    .uh_ios7 .uh,.uh_ios7{
      padding2em 0 0;
    }
注意:此方法会造成应用中固定定位的页面仍旧会造成状态栏被遮盖,我采用的是更改webview中的Classes文件夹 MainViewController.m
需要覆盖添加:  

- (void)viewWillAppear:(BOOL)animated
{
  if([[[UIDevice currentDevice]systemVersion ] floatValue]>=7)
  {
    CGRect viewBounds=[self.webView bounds];
    viewBounds.origin.y=20;
    viewBounds.size.height=viewBounds.size.height-20;
    self.webView.frame=viewBounds;
  }
  [super viewWillAppear:animated];
}
-(void)viewWillDisappear:(BOOL)animated
{
  if([[[UIDevice currentDevice]systemVersion ] floatValue]>=7)
  {
    CGRect viewBounds=[self.webView bounds];
    viewBounds.origin.y=20;
    viewBounds.size.height=viewBounds.size.height+20;
    self.webView.frame=viewBounds;
  }
    [super viewWillDisappear:animated];
}

 

 
 

 

posted @ 2017-09-13 10:43  白卫云  阅读(1623)  评论(0编辑  收藏  举报