gpt4 book ai didi

更改导航 Controller 框架后的 iOS 6 ViewController 框架问题

转载 作者:行者123 更新时间:2023-12-01 16:41:38 26 4
gpt4 key购买 nike

我有一个基于导航的应用程序,我必须在其中减少导航 Controller 的框架。
在 iOS 6 中,将导航 Controller 框架减少 50 像素后, subview Controller 的高度应为(480-64(导航栏 + 状态栏)-50(我已减少的高度)=366。但我得到的 View Controller 高度为 386 像素。这些额外的 20px 的 View Controller 位于导航栏下方。请引用附图。

谁能帮助我为什么会出现这个问题?在 iOS7 中它工作正常。

这是我的示例代码:
应用代理:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor yellowColor];

ViewController* vc =[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
vc.view.backgroundColor = [UIColor greenColor];
UINavigationController* navVC = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navVC;
[self.window makeKeyAndVisible];

UIGraphicsBeginImageContextWithOptions(CGSizeMake(36, 36), NO, 0.0);
UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:blank forBarMetrics:UIBarMetricsDefault];
return YES;
}

在 View Controller 的按钮单击事件中:
- (IBAction)buttonClicked:(id)sender {
CGRect navFrame = self.navigationController.view.frame;
navFrame.size.height -=50;
self.navigationController.view.frame = navFrame;
}

enter image description here

最佳答案

要显示广告,您不需要剪辑您的 View Controller View 。 Apple 提供了在您的应用程序中添加广告横幅的功能。请看this

另请务必阅读 Best Practices

也看看iAdSuite它提供了在您的应用中包含广告的绝佳示例。
这应该带您朝着正确的方向前进。我希望这有帮助

关于更改导航 Controller 框架后的 iOS 6 ViewController 框架问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23821307/

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