好吧伙计们和其他人一样的问题。如果我编辑 .plist 以支持所有方向,我就能让它工作,但我只需要在我的 MPMoviePlayerController 上支持旋转(也许在我的 MWPhotoBrwoser 图像上)
我的代码:Viewcontroller.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;
@end
视图控制器.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
真心希望能得到帮助!:)