【问题标题】:CGRectMake has moved behind my navigation barCGRectMake 已移到我的导航栏后面
【发布时间】:2013-10-05 20:12:47
【问题描述】:

在为 iOS 7 更新代码后,我遇到了一个让我一直困惑的问题。此代码在 iOS 6 中运行良好:

-(void)showPDFFile
{
NSString* fileName = @"Report.PDF";

NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
                                    NSDocumentDirectory,
                                    NSUserDomainMask,
                                    YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];

CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;

// This has been set to accomadate iPhone 5 screen size. //
if (iOSDeviceScreenSize.height == 568) {
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 455)];
}
else{
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 367)];
}


NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];

[self.view addSubview:webView];
} 

自从更新以来,webview 总是在导航栏后面结束。我试图更改 y 值以将其向下移动,但这使代码失败或无效。我知道这与新的边缘透明胶片有关,但我不确定如何解决这个问题。任何帮助都会很棒。谢谢

编辑: 澄清一下,我现在意识到这与 CGRectMake 无关。

【问题讨论】:

    标签: ios uiwebview ios7 cgrectmake


    【解决方案1】:

    尝试更改导航栏translucent,iOS7默认为YES

    self.navigationController.navigationBar.translucent = NO;
    

    【讨论】:

    • 这解决了我的问题。我没有意识到这是必要的。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-11
    • 2018-11-10
    相关资源
    最近更新 更多