I am having a strange problem trying to present MPMediaPickerController using currentModalViewController. I worked fine, but lately (maybe since 3.1, I don’t remember exactly how the last time it worked) MPMediaPickerController just refuses to show itself. The screen just stays black and nothing happens except the status bar at the top, and I am forced to exit the application.
Here is my code:
- (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";
[[UIApplication sharedApplication] setStatusBarHidden:NO animated: YES];
[musicController presentModalViewController: picker animated: YES];
[picker release];
}
As you can see, it basically copied verbatim from Apple examples, with some modifications, to make it work with Cocos2D. The window variable in the code is the application window, which is saved in the init method:
// Remember the window that the director is attached in
window = [[[[Director sharedDirector] openGLView] window] retain];
... . MPMediaPickerController , . , , , .
, .
: , :
[[Director sharedDirector] pause];
[[Director sharedDirector] detach];
[window addSubview:musicView];
:
[[[Director sharedDirector] openGLView] addSubview: musicView]
... , . , iPod , 3.0, , . , , - , , , - 20 , ( .) , Cocos2D -, Director openGLView.