首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >iOS 13: MPMediaPickerController -内部错误/无法找到所请求的应用程序扩展

iOS 13: MPMediaPickerController -内部错误/无法找到所请求的应用程序扩展
EN

Stack Overflow用户
提问于 2019-10-12 10:52:07
回答 3查看 5.2K关注 0票数 4

看来通用MPMediaPicker不再适用于ios13 (ipad 2,iphone )。

从那里复制的示例1:1没有显示媒体选择器https://developer.apple.com/documentation/mediaplayer/displaying_a_media_picker_from_your_app

关于如何恢复功能的提示??

注1

在使用这样的MPMediaPickerController

代码语言:javascript
运行
复制
    musicPickerView = [[UIView alloc] initWithFrame:fullScreenRect];
    musicPickerView.alpha = 0.0f;
    musicPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
    musicPicker.showsCloudItems               = false;
    musicPicker.showsItemsWithProtectedAssets = false;
    musicPicker.delegate                      = self;
    musicPicker.allowsPickingMultipleItems    = false;
    musicPicker.prompt                        = NSLocalizedString(@"Select a song", @"Select a song");
    musicPicker.view.frame                    = musicPickerView.bounds;
    [self addChildViewController:musicPicker];
    [musicPickerView addSubview:musicPicker.view];
    [self.view addSubview:musicPickerView];
    [musicPicker didMoveToParentViewController:self];
    [self fadeInMusicPicker:true];

根本不调用委托。没有显示日志,只显示本机警报。

我要让这个土生土长

内部误差

无法找到所请求的应用程序扩展。

取消

注2

这似乎是苹果音乐应用程序没有安装在该设备上的问题。有没有人知道有一种可靠的方法可以找出苹果音乐应用程序是否已经安装?

EN

回答 3

Stack Overflow用户

发布于 2019-10-24 12:39:18

苹果公司的Music应用程序似乎必须安装在该设备上。仍然没有100%的可重复性,但是安装了那个应用程序,我再也没见过这个问题了。

票数 4
EN

Stack Overflow用户

发布于 2019-10-24 01:25:27

您在info.plist中设置了媒体库的权限吗?NSAppleMusicUsageDescription

票数 0
EN

Stack Overflow用户

发布于 2019-10-25 14:52:47

与早期的iOS 13版本不同,MPMediaPicker需要用户授权。因此,您需要先处理身份验证,然后在用户授予权限时向选择器显示。你的代码如下,

代码语言:javascript
运行
复制
MPMediaLibraryAuthorizationStatus authorizationStatus = MPMediaLibrary.authorizationStatus;

    switch (authorizationStatus)
    {
        case MPMediaLibraryAuthorizationStatusAuthorized:
        {
            [self showPickerView];
            break;
        }
        case MPMediaLibraryAuthorizationStatusNotDetermined:
        {
            // Not yet authorized - request it from the system
            [MPMediaLibrary requestAuthorization:^(MPMediaLibraryAuthorizationStatus authorizationStatus)
             {
                 if ( authorizationStatus == MPMediaLibraryAuthorizationStatusAuthorized )
                 {
                     dispatch_async(dispatch_get_main_queue(), ^{

                            [self showPickerView];

                        });
                 }
                 else
                 {
                     PLog(@"The Media Library was not authorized by the user");

                 }
             }];
            break;
        }

        case MPMediaLibraryAuthorizationStatusRestricted:
        case MPMediaLibraryAuthorizationStatusDenied:
        {
            // user has previously denied access. Ask again with our own alert that is similar to the system alert
            // then take them to the System Settings so they can turn it on for the app

            break;
        }
    }


-(void)showPickerView
{
    musicPickerView = [[UIView alloc] initWithFrame:fullScreenRect];
    musicPickerView.alpha = 0.0f;
    musicPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
    musicPicker.showsCloudItems               = false;
    musicPicker.showsItemsWithProtectedAssets = false;
    musicPicker.delegate                      = self;
    musicPicker.allowsPickingMultipleItems    = false;
    musicPicker.prompt                        = NSLocalizedString(@"Select a song", @"Select a song");
    musicPicker.view.frame                    = musicPickerView.bounds;
    [self addChildViewController:musicPicker];
    [musicPickerView addSubview:musicPicker.view];
    [self.view addSubview:musicPickerView];
    [musicPicker didMoveToParentViewController:self];
    [self fadeInMusicPicker:true];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58353375

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档