Скриншот найден здесь: http://i.stack.imgur.com/fru4x.png
Итак, у меня есть UITableViewController, толкающий UIViewController, в котором есть объект MPMoviePlayer. Я обнаружил, что когда я загружаю в MPMoviePlayer в качестве подпредставления, он создает строку состояния. Эта строка состояния толкает вниз панель навигации вверх, вызывая пустое пространство. Я рассмотрел кучу разных тем на stackoverflow, и, похоже, ничего не работает:
iPhone: странное место в верхней части UINavigationController
Не уверен, почему UIView подталкивается примерно на 10px
Пустая (белая) строка под UITableView после закрытия MPMoviewPlayer из полноэкранного режима
Скрыть StatusBar от MPMoviePlayerController
UIViewController выдвигается со следующим кодом (PresetViewController.m):
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
//PresetNode *tempNode = [appDelegate.presetData objectAtIndex:row];
..... SOME DATA IS LOADED HERE
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
MoviePlayer *player = [[MoviePlayer alloc] initWithNibName:nil bundle:nil andVideoArray: presetVideoURLs];
[self.navigationController pushViewController:player animated:NO];
[player playVideoAtIndex:0];
[player release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Когда контроллер представления загружается, по какой-то причине он загружается в строке состояния вверху его представления, хотя я использую этот код в MoviePlayer.m:
- (void)viewDidAppear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
Я установил фильм в альбомный режим и проиграл его. Затем я проверяю, нажата ли готовая кнопка. Если кнопка готово нажата, я выскакиваю вид. По какой-то причине, когда представление прерывается, контроллер uitableview за ним отталкивается на несколько пикселей. Строка состояния, созданная киноплеером, толкает все вниз. Вот код фильма (MoviePlayer.m):
-(void) playVideoAtIndex: (NSInteger)index{
NSString *rootPath = [[NSBundle mainBundle] resourcePath];
NSString *filePath = [rootPath stringByAppendingPathComponent: [self.movieArray objectAtIndex:index]];
NSURL *fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
self.yourMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: fileURL];
[yourMoviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[self navigationController] setNavigationBarHidden: YES];
yourMoviePlayer.scalingMode = MPMovieScalingModeFill;
[[yourMoviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI/2)];
self.yourMoviePlayer.view.frame = self.view.frame;
[yourMoviePlayer setFullscreen:YES animated:NO];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(checkForNextMovie:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:yourMoviePlayer];
[[self view]addSubview:yourMoviePlayer.view];
//[[self navigationController] presentMoviePlayerViewControllerAnimated:self];
//---play movie---
[yourMoviePlayer play];
}
-(void) checkForNextMovie:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
NSNumber *reason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
[yourMoviePlayer release];
if((currentIndex+1) == [self.movieArray count] || [reason intValue] == MPMovieFinishReasonUserExited){
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
[player.view removeFromSuperview];
[[self navigationController] setNavigationBarHidden: NO];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//self.wantsFullScreenLayout = YES;
[[self navigationController] popViewControllerAnimated:NO];
if ([UIApplication sharedApplication].statusBarOrientation != self.interfaceOrientation) {
[[UIApplication sharedApplication] setStatusBarOrientation:self.interfaceOrientation animated:NO];
}
}
else{
currentIndex++;
[self playVideoAtIndex: currentIndex];
}
}