gpt4 book ai didi

iPhone UIViewController 进入状态栏

转载 作者:技术小花猫 更新时间:2023-10-29 11:09:45 25 4
gpt4 key购买 nike

我有一个 UIView 和一个 UIController View 。我的是标准的 320x460 View 。在 applicationDidFinishLaunching 中,我执行以下操作:

[window addSubview:[controller view]];

奇怪的是 UIView 位于状态栏下方(就像缺少 socket 一样)。但是,如果我将 iPhone 旋转到一边然后再旋转回来,它会显示正常。

这是预期的行为吗(我敢打赌我可以通过设置偏移来修复它)还是我做错了什么?

最佳答案

我在通过 presentModalViewController 显示 UIViewController 时遇到了这个问题。

您可以通过 View 出现后手动调整 Controller View 的大小来解决这个问题:

- (void) viewDidAppear: (BOOL) animated {
//manually adjust the frame of the main view to prevent it from appearing under the status bar.
UIApplication *app = [UIApplication sharedApplication];
if(!app.statusBarHidden) {
[self.view setFrame:CGRectMake(0.0,app.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height - app.statusBarFrame.size.height)];
}
}

关于iPhone UIViewController 进入状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1871189/

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