ios11 cordova 对ios 一些配置

1  问题发现: ios app下 内容可以上下滑动 内容不固定 (webview页面遮挡状态栏或者距离太近 显示不友好)

解决问题:

ios 11 新增 :meta 标签中 添加 viewport-fit=cover,这是 ios 11 新增的设置,可以让页面全屏展示。

<meta name="viewport" content="initial-scale=1, width=device-width, height=device-height, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover">
然后 控制webview的frame,顶部添加20的view

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    UIView *statusBarView = [[UIView alloc]   initWithFrame:CGRectMake(0, 0,    self.view.bounds.size.width, 20)];
    statusBarView.backgroundColor = [HTMISettingManager manager].navigationBarColor;
    [self.view addSubview:statusBarView];
}
- (void)viewWillAppear:(BOOL)animated
{
     CGRect viewBounds = [self.webView bounds];
     viewBounds.origin.y = 20;
     viewBounds.size.height = viewBounds.size.height - 20;
     self.webView.frame = viewBounds;
    [super viewWillAppear:animated];
}

以下是代码: 

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    UIView *statusBarView = [[UIView alloc]   initWithFrame:CGRectMake(0, 0,    self.view.bounds.size.width, 20)];
    statusBarView.backgroundColor = [HTMISettingManager manager].navigationBarColor;
    [self.view addSubview:statusBarView];
}
- (void)viewWillAppear:(BOOL)animated
{
     CGRect viewBounds = [self.webView bounds];
     viewBounds.origin.y = 20;
     viewBounds.size.height = viewBounds.size.height - 20;
     self.webView.frame = viewBounds;
    [super viewWillAppear:animated];

在MainViewConController.m中 增加

   CGRect viewBounds = [self.webView bounds];
     viewBounds.origin.y = 20;
     viewBounds.size.height = viewBounds.size.height - 20;
     self.webView.frame = viewBounds;

解决完毕

也可以借鉴以下文章

https://blog.csdn.net/lovelyelfpop/article/details/79460700?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-2-79460700.nonecase&utm_term=cordova%20ios%20%E5%85%A8%E5%B1%8F&spm=1000.2123.3001.4430

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值