如何设置MPMediaPickerController的正确方向?
我已经在shouldAutorotateToInterfaceOrientation中返回YES,但我有糟糕的横向框架(如果先在纵向显示MPMediaPickerController,反之亦然)。
我旋转我的设备杂乱无章,有时帧设置为纠正自己!我已经找到了通过旋转设置框架的方法-需要旋转到180度。例如,如果你在肖像中有好的边框,当你旋转到横向时-你有坏的边框(从Portatait),但如果你旋转到其他横向( 180度),那么帧设置为横向...为什么?
如何才能始终正确设置旋转后的帧?
致以敬意,
发布于 2012-06-28 14:24:19
我不确定你是否对这个解决方案感兴趣,因为你在2010年就问过这个问题。总之,经过几次搜索,我找到了以下内容:
下面是粗略的代码。它是有效的,但需要一些清理。最好检查一下弹出窗口是否为空,否则每次用户点击按钮时,它都会堆积起来。
- (IBAction)showMediaPicker:(id)sender
{
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = YES;
mediaPicker.prompt = @"Select musics...";
UIPopoverController *colorPickerPopover = [[[UIPopoverController alloc]
initWithContentViewController:mediaPicker] retain];
[colorPickerPopover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}更多注意事项:此IBAction绑定到工具栏按钮。
发布于 2012-12-26 09:06:12
我只是简单地把它推到我的导航控制器上:
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = NO;
mediaPicker.prompt = @"Select songs...";
[[self navigationController] pushViewController:mediaPicker animated:YES];当然,这只在导航控制器的上下文中有效,但它有效且简单!
发布于 2012-03-13 21:29:20
这里有一些示例代码你可以尝试一下,旋转后你必须将媒体播放器视图设置在self.view的中心,这里有一些示例代码…你必须首先添加MediaPlayer框架...
NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"PATRON_LOGO_3" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *playerCtrl = [[MPMoviePlayerController alloc]initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:playerCtrl.view];
[playerCtrl play];我认为它工作得很好,这是用于肖像的横向模式,我们必须根据肖像边框来设置边框,例如..
playerCtrl.view.frame = CGRectMake(0,0,480,320);
在那之后,我们必须设置到视点的中心。
https://stackoverflow.com/questions/3687388
复制相似问题