gpt4 book ai didi

objective-c - 如何获取没有导航栏的 UIView 的高度?

转载 作者:搜寻专家 更新时间:2023-10-30 20:21:39 24 4
gpt4 key购买 nike

我正在尝试在一个干净的 UIViewController 中添加一个 UIWebView,它在我的 Storyboard 中嵌入了一个导航 Controller :

UIWebView *webView =[[UIWebView alloc] initWithFrame:self.view.bounds)];
webView.delegate = self;
[self.view addSubview:webView];

问题是,self.view.bounds.size.height 是 460,这似乎是包括导航栏在内的整个 View 的高度。我可以减去 self.view.frame.origin.y 的值(即 20)并获得所需的高度 440,但是是否有更常见的方法来执行此操作?

编辑

请在这里查看我的小代码示例:http://uploads.demaweb.dk/WebViewTest.zip

当您向下滚动到 UIWebView 的底部时,网站的最后一部分不会显示,因为 webView 太高了。

![在此处输入图片描述][1]

最佳答案

解决方案

在 UIWebView 中设置 autoresizingMask 解决了我的问题:

self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

关于objective-c - 如何获取没有导航栏的 UIView 的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9331106/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com