3

我在我的 iPad 应用程序中使用主从应用程序模板。
我有包含视频列表的主视图。选择任何列表项时,它开始在详细视图上播放该项目的视频。
我正在使用 MPMoviePlayerController 播放视频。
如果我按下全屏图标,播放器应该填满整个屏幕(主视图和详细视图,而不仅仅是详细视图)。
我怎么能这样做?请帮忙!

4

1 回答 1

10

MasterViewcontroller您可以使用 Delegate隐藏或显示UISplitViewController

- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation

- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem;

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc;

更新:-

示例代码:-

在DetailViewController.h类中设置一个BOOL

@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>

@property (nonatomic) BOOL  IShide;

并在您的.M类中执行以下方法

-(void)hideMaster:(id)hideState
{

    _IShide=!self.IShide;
    [self.splitViewController.view setNeedsLayout];
    self.splitViewController.delegate = nil;
    self.splitViewController.delegate = self;

    [self.splitViewController willRotateToInterfaceOrientation:[UIApplication    sharedApplication].statusBarOrientation duration:0];

 //also put your `MPMoviePlayerController` Fullscreen Method here
}

#pragma mark - Split view

-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return self.IShide;
}
- (void)viewDidLoad
{

    UIBarButtonItem *Fullscreen = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"FullScreen", nil) style:UIBarButtonItemStylePlain target:self action:@selector(hideMaster:)];
     [self.navigationItem setRightBarButtonItem:Fullscreen animated:YES];
    [super viewDidLoad];

}

当您单击MPMoviePlayerController使用此事件调用此委托的全屏事件时,您隐藏和显示 MasterViewController。

代码输出是

在此处输入图像描述

于 2013-08-14T06:55:14.813 回答