gpt4 book ai didi

rotation - 在 iOS 8 中观看视频后出现内容偏移问题

转载 作者:行者123 更新时间:2023-12-02 07:09:28 25 4
gpt4 key购买 nike

我有一个 TabBarController,支持InterfaceOrientations - UIInterfaceOrientationMaskPortrait。当我开始从其中一个选项卡观看视频、将设备旋转到横向,然后从全屏退出时,导航栏会在状态栏下方向上移动。为什么会发生这种情况以及如何解决?

最佳答案

这是一种黑客攻击,但在我的 View Controller 中有效,包含 UIWebView 和从

您会看到导航栏抖动,因为在视频全屏窗口消失后调用了 UIWindowDidBecomeHiddenNotification

- (void)viewDidLoad
{
[super viewDidLoad];
// NOTE: I'm not sure, but MPMoviePlayerWillExitFullscreenNotification won't work
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeHidden:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeHidden:) name:UIWindowDidBecomeHiddenNotification object:nil];
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)windowDidBecomeHidden:(NSNotification *)notification
{
UIView *navbar = self.navigationController.navigationBar;
CGRect barFrame = navbar.frame;
barFrame.origin.y = 20;
self.navigationController.navigationBar.frame = barFrame;
UIView *navbarBack = nil;
for (UIView *view in navbar.subviews) {
if ([NSStringFromClass([view class]) isEqual:@"_UINavigationBarBackground"]) {
navbarBack = view;
break;
}
}
CGRect backFrame = navbarBack.frame;
backFrame.origin.y = -20;
backFrame.size.height = 64;
navbarBack.frame = backFrame;
[navbar.superview setNeedsLayout];
}


UIView *navbarBack = [navbar.subviews bk_match:^BOOL(UIView *view) {
return [NSStringFromClass([view class]) isEqual:@"_UINavigationBarBackground"];
}];

关于rotation - 在 iOS 8 中观看视频后出现内容偏移问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25913149/

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