好了伙计们和其他人一样的问题。如果我编辑了支持所有方向的.plist,我就能让它工作,但我只需要在我的MPMoviePlayerController (可能还有我的MWPhotoBrwoser图像)上支持旋转。
我的代码:ViewControler.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MusikViewController : UIViewController{
AVAudioPlayer *audioPlayer;
}
//tilføjer vores film afspiller
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
//Laver de to knapper
//Musik knap
- (IBAction)Play:(UIButton *)sender;
//Film knap
- (IBAction)playButton:(id)sender;
//info knap
- (IBAction)info:(id)sender;
@endViewcontroller.m
#import "MusikViewController.h"
@implementation MusikViewController
@synthesize moviePlayer;
- (IBAction)Play:(UIButton *)sender
{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/roteWeste.mp4", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
if (audioPlayer == nil){
NSLog(@"Der skete en fejl, prøv at genstarte app'en, hvis problemet bliver ved, prøv da at send en mail til Mrostgaard@gmail.com");
}
else
[audioPlayer play];
}
- (IBAction)playButton:(id)sender {
NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"RoteVeste2" ofType:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:videoFile]];
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.controlStyle = MPMovieControlModeVolumeOnly;
[moviePlayer play];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO;
}
else
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO; }
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[audioPlayer stop]; // Or pause
}
- (IBAction)info:(id)sender {
}
@end我就是不能让它工作。代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO;
}
else
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO; }
}这只是我最新的尝试,但我已经尝试了几乎所有的东西,只需要旋转MPMovieViewController即可。
我甚至试过了,不能让它工作http://fostah.com/ios/2012/09/27/ios6-orientation-handling.html
真的希望能得到一些帮助!:)
发布于 2012-12-10 18:16:09
当你读到你的问题:“如果我编辑了.plist以支持所有方向,我就能让它工作,但我只需要在我的MPMoviePlayerController (也许还有我的MWPhotoBrwoser图像)上支持旋转”,第一句话是你应该允许.plist中的所有方向。plist中允许的方向应该是应用程序中不同视图控制器必须支持的所有方向的联合。
无论你在一个特定的视图控制器中做什么,你永远不能允许旋转到你的plist中不允许的方向。
然后由所有单独的视图控制器来决定特定的视图控制器允许什么方向。因此,在步骤中:
shouldAutorotateToInterfaceOrientation (iOS5) shouldAutorotate / supportedInterfaceOrientations (iOS6)
发布于 2015-07-22 22:12:34
在AppDelegate.h中添加以下方法
-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(!ISIPAD)){
if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]] && ![[self.window.rootViewController presentedViewController] isBeingDismissed])
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
return UIInterfaceOrientationMaskAllButUpsideDown ;
}https://stackoverflow.com/questions/13773179
复制相似问题