Objective c 在xcode中固定mediaplayer在横向和纵向模式下的位置
我在xcode中创建了一个mediaplayer,视频下面有一个标题。当设备旋转到横向模式时,我的布局有问题。我实现了一个changedView方法,在设备旋转时移动mediaplayer。如果您以纵向模式启动,然后旋转设备,这将非常有效。但是,当您处于纵向模式并使用mediaplayer切换到屏幕时,它不会移动到正确的位置。 我在viewdidload方法中实现了该方法,但这并没有解决问题。当我已经在横向模式下导航到页面时,如何使其在横向模式下处于正确的位置 包含媒体播放器的视图控制器的我的代码:Objective c 在xcode中固定mediaplayer在横向和纵向模式下的位置,objective-c,xcode,media-player,screen-rotation,Objective C,Xcode,Media Player,Screen Rotation,我在xcode中创建了一个mediaplayer,视频下面有一个标题。当设备旋转到横向模式时,我的布局有问题。我实现了一个changedView方法,在设备旋转时移动mediaplayer。如果您以纵向模式启动,然后旋转设备,这将非常有效。但是,当您处于纵向模式并使用mediaplayer切换到屏幕时,它不会移动到正确的位置。 我在viewdidload方法中实现了该方法,但这并没有解决问题。当我已经在横向模式下导航到页面时,如何使其在横向模式下处于正确的位置 包含媒体播放器的视图控制器的我的代
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self changedView];
self.title =@"Catalase";
[self.cAidButton setTitle:@"Identification Flowchart" forState:UIControlStateNormal];
NSURL* catalaseurl = [[NSURL alloc]initWithString:@"example.com"];
catalaseplayer = [[MPMoviePlayerController alloc]initWithContentURL:catalaseurl];
[catalaseplayer.view setFrame:CGRectMake(50, 214, 674, 481)];
[self.view addSubview:catalaseplayer.view];
//additional customization
catalaseplayer.fullscreen = YES;
catalaseplayer.shouldAutoplay = NO;
catalaseplayer.controlStyle = MPMovieControlStyleDefault;
}
-(void)changedView{
UIInterfaceOrientation theOrientation = self.interfaceOrientation;
if(theOrientation == UIInterfaceOrientationPortrait || theOrientation == UIInterfaceOrientationPortraitUpsideDown){
[catalaseplayer.view setFrame:CGRectMake(50, 214, 674, 481)];
}
else{
[catalaseplayer.view setFrame:CGRectMake(152, 95, 721, 493)];
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self changedView];
}