MPMediaPickerController 选择的索引不起作用

发布于 2024-10-28 01:57:47 字数 939 浏览 0 评论 0原文

我正在实现一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒夜笙歌凉 2024-11-04 01:57:47

不幸的是,您无法设置 MPMediaPickerController 的选定索引。它不是常规的 UITabBarController。如果您想更改选定的索引、颜色等,则必须对其进行子类化。对不起。

查看 http://bit.ly/krMNMK 以获取更多参考。

You cannot set the selected index of a MPMediaPickerController unfortunately. It's not a regular UITabBarController. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文