- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在尝试使用presentModalViewController 呈现MPMediaPickerController 时遇到了一个奇怪的问题。我让它工作得很好,但最近(也许从 3.1 开始,我不记得它上次工作是什么时候了)MPMediaPickerController 只是拒绝显示自己。屏幕仍然是黑色的,除了顶部的状态栏之外什么都没有,我被迫退出应用程序。
这是我的代码:
// Show the music picker, allowing the user to create a playlist
- (void) showMusicPicker;
{
[[Director sharedDirector] pause];
[[Director sharedDirector] detach];
musicView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[window addSubview:musicView];
musicController = [[UIViewController alloc] init];
[musicController setView:musicView];
[musicController setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = @"Select songs to play";
// The media item picker uses the default UI style, so it needs a default-style
// status bar to match it visually
[[UIApplication sharedApplication] setStatusBarHidden:NO animated: YES];
[musicController presentModalViewController: picker animated: YES];
[picker release];
}
正如您所看到的,它主要是从 Apple 的示例中逐字复制的,并进行了一些修改以使其能够与 Cocos2D 一起使用。代码中的window变量是应用程序窗口,在init方法中保留:
// Remember the window that the director is attached in
window = [[[[Director sharedDirector] openGLView] window] retain];
该方法的其余部分似乎工作正常... Controller 从窗口分离并出现状态栏。但是 MPMediaPickerController 应该出现在屏幕上,但它没有出现。正如我提到的,不久前它运行良好,所以我对这里发生的事情感到困惑。
感谢您提供的任何帮助。
编辑:我注意到,如果我注释掉这些行:
[[Director sharedDirector] pause];
[[Director sharedDirector] detach];
[window addSubview:musicView];
并将它们替换为:
[[[Director sharedDirector] openGLView] addSubview: musicView]
...然后选择器 Controller 将按其应有的方式显示。这是我在 3.0 发布后第一次实现 iPod 库访问时添加 View 的方式,因为它比当前的方式稍微简单一些。然而,这种方法的问题是,一旦选择器 Controller 被关闭,在触摸事件上向我报告的所有触摸坐标都会变得不准确 - 它们比应有的高度(纵向方向)高出大约 20 像素。不确定这是否是 Cocos2D 的错误或什么,但它几乎排除了直接在 Director 的 openGLView 上呈现 Controller 的可能性。
最佳答案
好吧,我想我已经弄清楚了。对于其他可能发现自己处于这种情况的人来说,这是一种工作方法(我犹豫是否要说“正确的方法”):
- (void) showMusicPicker;
{
[[Director sharedDirector] pause];
musicController = [[UIViewController alloc] init];
[musicController setView:[[Director sharedDirector] openGLView]];
[musicController setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = @"Select songs to play";
// The media item picker uses the default UI style, so it needs a default-style
// status bar to match it visually
[[UIApplication sharedApplication] setStatusBarHidden:NO animated: YES];
[musicController presentModalViewController: picker animated: YES];
[picker release];
}
这会显示选取器,并且在选取器关闭后不会导致 Director 报告不正确的坐标。
关于iphone - PresentModalViewController 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1450375/
我是 ios 开发的新手,现在我正在我的应用程序上做一些动画。在我的应用程序中,主视图底部有一个菜单,有两个按钮,一个用于隐藏菜单,另一个用于显示菜单。我的需要菜单的显示和隐藏功能是否正常工作[sel
我知道,这是最简单的事情之一。但几天来我一直在努力反对这一点。我过去已经做过很多次了,但由于某种原因,尝试呈现模态视图 Controller 只会使应用程序崩溃到黑屏。控制台中没有报告任何内容。我希望
我在尝试使用presentModalViewController 呈现MPMediaPickerController 时遇到了一个奇怪的问题。我让它工作得很好,但最近(也许从 3.1 开始,我不记得它
我有一个 View Controller ,我正在以模态方式呈现它,如... UIViewController *myWindow = [[UIViewController alloc] init];
这是我的代码: ViewController *vc = [[ViewController alloc] initWithNibName:@"TableView" bundle:nil]; [self
我已经发布了如何显示 modalViewController 但现在我需要将其删除并返回到我的 tabbarController 并显示他的 View 。谢谢 最佳答案 从 modalViewCont
我需要一个像 UIModalTransitionStyleCoverVertical 这样的 presentModalViewController 动画,但是从左到右而不是从底部。 解决这个问题的唯一
我想在 View 的中心展示一个带有小框架的 modalViewController。 那可能吗? 即使我为 viewController 对象设置了一些框架,presentModelViewCont
我在 Controller 上调用 presentModalViewController,虽然 Controller 确实出现了,但它出现在屏幕上时并没有动画。任何想法为什么会发生这种情况。我不认为它
我位于 Root View Controller 内。然后分配第二个 View Controller SecondViewControl *second=[[SecondViewCo
-(void)backAction:(id)sender { SecondViewController *viewCtrl = [[SecondViewController alloc] ini
所以我希望这很简单并且可以做到: 我有一个执行 Facebook 登录的 LoginViewController。我有代码设置,这样一旦用户输入他或她的信息并单击登录,它就会返回到同一个 LoginV
我的加载应用程序检查用户是否在文件系统中有文件,如果没有,它会使用 presentModalViewController 弹出一个 View Controller ,在用户使用该 View Contr
我有一个奇怪的僵尸错误,它似乎是从一个长期存在的应用程序中偷偷摸摸的。我喜欢认为我知道自己在做什么,僵尸通常很容易修复,但这个让我感到困惑。 Instruments 报告僵尸对象是我作为模态视图 (M
我有一个 UINavigationController,在 UINavigationBar 上有一个按钮。当我按下这个按钮时,一个新的 UINavigationController 以模态方式呈现为
我有一个试图显示为 UIModalPresentationFormSheet 的 View Controller ,但它不显示其 UIToolbar。我怎样才能让工具栏显示在上面? Connectio
我有一个 UIViewController(parent)调用 presentModalViewController 和 viewDidLoad 上的另一个 UIViewController(chil
我有一个基于导航栏的应用程序,在应用程序的一个特定位置,我在导航栏上有一个按钮,该按钮应该使用翻转过渡呈现一个新 View (本质上是将用户从表格 View 带到 map View ) .我目前正在使
要使用 presentModalViewController,我必须 alloc 和 initWithNibName:bundle: 一个 View 。我的问题是:我在哪里发布它? dismissMo
我想在启动时使用模式 UITableView 来询问用户密码等,如果他们还没有配置的话。但是,调用 uitableview 的命令似乎在 viewDidLoad 中不起作用。 启动代码: - (voi
我是一名优秀的程序员,十分优秀!