- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 MPMoviePlayerController
对象,可以纵向或横向全屏播放视频。如果我在播放视频时旋转方向,并在视频开始播放并且视频状态栏可见后几秒钟内进行旋转,那么当视频结束时我的导航栏是完美的。但是,如果我等到视频状态栏在视频播放几秒钟后消失,然后旋转方向,当视频结束时,我的 navigationBar
会部分隐藏在状态栏后面,就像向上推一样。
你见过这样的东西吗?
我能够轻松地重现此错误。我创建了一个新的 Single View App,并简单地添加了一个按钮和一个导航栏。如果我在播放视频时旋转方向,点击以启用全屏并且视频状态栏仍然可见,当视频结束时,一切都很好。但是,如果我在视频状态栏消失后等待旋转,当我旋转并且视频结束时,导航栏位于状态栏下方。看图:
这是我使用的简单代码:
- (void) playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: @"movie" ofType: @"mov"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: url];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(moviePlayBackDidFinish:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview: moviePlayer.view];
[moviePlayer setFullscreen: YES animated: YES];
- (void) moviePlayBackDidFinish: (NSNotification *) notification
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver: self
name: MPMoviePlayerPlaybackDidFinishNotification
object: player];
if ([player respondsToSelector: @selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
这是我目前所处的位置,下面给出了建议。我一定是出了什么问题,因为不幸的是我仍然有同样的问题。
这是方法onPlayerWillExitFullScreen
UIView *view = [[[UIApplication sharedApplication] delegate].window.subviews lastObject];
if (view) {
[view removeFromSuperview];
[[[UIApplication sharedApplication] delegate].window addSubview:view];
}
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver: self
name: MPMoviePlayerWillExitFullscreenNotification
object: player];
这是我当前的 playMovie
方法:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: @"movie" ofType: @"mov"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: url];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(moviePlayBackDidFinish:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: moviePlayer];
[[NSNotificationCenter defaultCenter]addObserver: self
selector: @selector(onPlayerWillExitFullScreen:)
name: MPMoviePlayerWillExitFullscreenNotification
object: self.moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview: moviePlayer.view];
[moviePlayer setFullscreen: YES animated: YES];
最佳答案
好吧,所以我在我的应用程序中发现了同样的错误,首先是在 UIWebView 中,然后是在 MPMoviePlayerController 中,我解决了这个问题,将这段代码放在我的 View Controller 中。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
棘手的错误,棘手的修复。
关于iphone - navigationBar 和 MPMoviePlayerController 的异常行为。 iOS 中的错误还是我的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8352045/
我需要管理嵌入在使用标准、浅色、模糊层的 NavigationController 中的两个 ViewController 之间的转换。应用程序这部分中的所有 ViewController 看起来都非
我有一个包含 3 个不同 NavigationController 的 Storyboard: 在第一个 NavigationController 的根 Controller 中,我在代码中添加了一个
先说说我的情况。我在我的 appDelegate 中设置了 UINavigationBar 颜色,例如: [[UINavigationBar appearance] setBarTintColor:[
这两种说法有什么区别。为了隐藏导航栏,我使用以下语句之一在 viewWillAppear 方法中隐藏导航栏,如下所示: -(void)viewWillAppear:(BOOL)animated {
目前我找不到任何方法来更改 SwiftUI 中导航栏的颜色/背景。有小费吗? 最佳答案 为了改变所有 View Controller 的导航栏颜色,你必须在 AppDelegate.swift 中设置
我可以自定义 QlPreviewController Controller 中导航栏的颜色吗? 我尝试过以下 [[UINavigationBar appearanceWhenContainedIn:
我正在开发一款带有 webview 布局的安卓游戏。我想在用户玩游戏时隐藏导航栏。我找到了一些解决方案,但是当我触摸屏幕时,导航栏出现了。 我做错了什么?这是我的无效解决方案: int mUIFla
我的导航栏上有这种奇怪的行为: 而且我不知道如何解决它。 我在 Storyboard上的设置是: 我希望条形颜色清晰,以便获得完美的模糊效果。 有任何想法吗? 感谢您的关注。 最佳答案 尝试这些设置可
我正在尝试实现一种 AlertWindow 类的东西,我正在使用 WindowsManager 的实例从服务。 View 可见且可访问。但是屏幕上 NavigationBar 上的后退/主页按钮似乎没
我想隐藏NavigationBar和stateBar以显示全屏图像,但似乎navigationBar并未完全隐藏: 代码如下: [[UIApplication sharedApplication]
我找不到关于如何使用 完成此操作的任何文档组件...基本上,当我的一个场景加载时,我希望能够传递一个 route.navBarColor到我的导航器,它将自动更改栏的背景颜色。 我尝试使用 {nav
我正在向导航栏层添加渐变,并且效果很好。当我推送另一个 View Controller 和弹出 View Controller 时,问题就来了。父 View Controller 有右边的条形按钮项目
我在 iOS 7 模拟器和设备上都遇到了一个奇怪的图形问题。 在按下 TableView 中的单元格后,我以编程方式从 Storyboard 中调用 segue: [self performSegue
我有一个 NavigationViewController,它的根是一个普通的 UIViewController。我通过以下方式以编程方式呈现 TableViewController: self.pe
我有 2 个 VC。在这两种情况下,我都将代码编写为 NavigationController 外观,但是当我从第二个 VC 返回到第一个时,我的一切都是黑色的...... 第一位风投: overri
我正在使用带有 UITableView 的普通 View Controller ,它嵌入到导航 Controller 中,导航 Controller 嵌入到标签栏 Controller 中: 标签栏
我的 Storyboard中有一个导航栏,并设置了以下约束: Horizontal Space - (-16) - View Navigation Bar Horizontal Space - (-1
我的结构如下: ContainerView --embed segue--> NavigationController --> UITableViewController A --push segue
嘿,我在 UINavigationController 中有一堆 UIViewController。通常,标题(或 NavigationItem 的标题)决定了 NavigationBar 中显示的标
Second Image 问题是当我弹出我的 Controller 时,导航栏变成黑色,这非常烦人。需要帮助! 最佳答案 当您弹出屏幕时,您会回到上一屏幕。在预览屏幕中,您必须在 viewWillAp
我是一名优秀的程序员,十分优秀!