iPad上的MPMediaPickerController方向 [英] MPMediaPickerController orientation on iPad

查看:192
本文介绍了iPad上的MPMediaPickerController方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置MPMediaPickerController的正确方向?

How can I set correct orientation of MPMediaPickerController ?

我在shouldAutorotateToInterfaceOrientation中返回YES,但我的Landscape框架不好(如果在Portrait中首先显示MPMediaPickerController,反之)。

I've return YES in shouldAutorotateToInterfaceOrientation, but i have bad frame for Landscape (if show MPMediaPickerController in Portrait first, and conversely).

我正在混乱地旋转我的设备,有时候设置框架来纠正自己!
我找到了通过旋转设置框架的方法 - 需要旋转到180度。
例如,如果你在Portrait中有一个好帧,当你旋转到Landscape时 - 你有一个坏帧(来自Portatait),但如果你旋转到其他景观(到180度),然后帧设置为Landscape .. 。
为什么?

I've rotating my device chaotically and sometime frame set to correct himself! I've find the method to set frame by rotating - need rotate to 180 degreess. For example, if you have good frame in Portrait, when you rotate to Landscape - you have bad frame (from Portatait), but if you rotate to other landscape (to 180 degreess), then frame set to Landscape... Why ?

如何在旋转后正确设置帧?

How can i set the frame after rotation correct always ?

问候,

推荐答案

不确定您是否对此解决方案感兴趣,因为您在2010年提出了这个问题。
无论如何,经过几次搜索后,我找到了:

Not sure whether you are interested in the solution or not, since you asked this in 2010. Anyway, after a few searches here is what I found:


  1. MPMediaPickerController不支持风景定位。

  1. MPMediaPickerController DOES NOT SUPPORT LANDSCAPE ORIENTATION.

为了使MPMediaPicker在横向方向上显得很好,我们可以使用PopOverController。基本上,我们创建一个弹出窗口,并将选择器插入其中。从rootViewController正确显示时,PopOverController确实会遵循设备的方向。

In order to make the MPMediaPicker appear nicely in landscape orientation, we can make use of PopOverController. Basically, we create a pop over, and insert the picker into it. PopOverController, when displayed properly from the rootViewController, will indeed follow the orientation of the device.

这是粗略的代码。它有效,但需要一些清理。你可能最好检查
popover是否为零,否则每次用户点击按钮时它都会自动叠加。

Here is the rough code. It works, but needs some cleaning up. Probably best you check whether the popover is nil or not, otherwise it will just stack up on itself each time the user tap on the button.

- (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与工具栏绑定栏按钮。

A little more note: this IBAction is tied to a Toolbar Bar button.

这篇关于iPad上的MPMediaPickerController方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆