MPMediaPickerController 选择的索引不起作用
我正在实现一个基于 MPMediaPickerController 的应用程序。当我尝试打开音乐应用程序时,它需要将我带到“播放列表”选项卡,而不是显示“音乐”选项卡。为此,我使用选定的索引属性来实现它。但还是不行。
以下是我的代码:
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some 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] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];
picker.tabBarController.selectedIndex=1;
[picker.tabBarController.selectedViewController viewDidAppear:YES];
[self presentModalViewController: picker animated: YES];
[picker release];
I am implementing a MPMediaPickerController based application. In that When I tried to open music application it need to takes me to the "playlists" tab instead of showing "Music" tab. For this I used selected index property to make it. But still it doesn't work.
Following is my code:
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some 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] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];
picker.tabBarController.selectedIndex=1;
[picker.tabBarController.selectedViewController viewDidAppear:YES];
[self presentModalViewController: picker animated: YES];
[picker release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,您无法设置
MPMediaPickerController
的选定索引。它不是常规的UITabBarController
。如果您想更改选定的索引、颜色等,则必须对其进行子类化。对不起。查看 http://bit.ly/krMNMK 以获取更多参考。
You cannot set the selected index of a
MPMediaPickerController
unfortunately. It's not a regularUITabBarController
. If you want to change the selected index, color, etc, you'll have to subclass it. Sorry.Check http://bit.ly/krMNMK for more reference.