半透明,setStatusBarStyle,UIWebView [英] Translucent , setStatusBarStyle, UIWebView
问题描述
我正在使用UIWebView,我想要的是webView不要说唱这个观点。
I'm working on the UIWebView and what I want is for the webView not to over rap the view.
所以这是问题所在。我设置了UIWebView,状态栏覆盖在内容上。
我该如何处理?我编写的是当我创建UIImage视图时,但当时有导航栏,它运行良好。
so here is the question. I set the UIWebView ,and the status bar is overlaid over the content. How can I handle this? I coded as when I made the UIImage view, but at that time there is the navigation bar, and it worked well.
我也做了setFrame:CGRectMake(0,20) )....但也行不通。为什么[setFrame];方法不起作用?请提出任何想法。
Also I did setFrame:CGRectMake(0, 20).... but also doesn't work. why the [ setFrame]; method doesn't work? Any ideas please.
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
[self.webView setFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];
NSURL *myURL = [NSURL URLWithString:@"http://www.amazon.com"];
NSURLRequest *myURLReq = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:myURLReq];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
@end
UPDATE:我关闭了自动布局并更改了setFrame:CGRectMake(0, 20 ),现在它们没有重叠。但我想知道为什么我们需要设置它?如果我将状态栏设置为半透明,则有意义。但我把它设置为默认值,它应该开始在(0,20)状态栏的正下方绘制屏幕。
UPDATE: I switched off the Auto-layout and change setFrame:CGRectMake(0, 20) and now they are not overlaid. But I wonder why we need to set this? If I set the status bar translucent , it makes sense. But I set it as the default, which is supposed to start to draw the screen right below the status bar at (0,20).
推荐答案
试试这个
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
[self.webView setFrame:CGRectMake(0.0, 20.0, self.view.frame.size.width, self.view.frame.size.height)];
NSURL *myURL = [NSURL URLWithString:@"http://www.amazon.com"];
NSURLRequest *myURLReq = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:myURLReq];
}
您的自动调整大小面具应该是这样的。
最终输出:
这篇关于半透明,setStatusBarStyle,UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!