gpt4 book ai didi

ios - MPMediaPickerController 在启动后关闭 (Swift)

转载 作者:可可西里 更新时间:2023-11-01 00:33:05 24 4
gpt4 key购买 nike

当我单击单元格以打开 MPMediaPickerController 时,它会在启动时打开。

gif

class MediaViewController: UITableViewController, MPMediaPickerControllerDelegate

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 2 {
if indexPath.row == 0 {
let mediaPicker = MPMediaPickerController(mediaTypes: MPMediaType.anyAudio)
mediaPicker.delegate = self
mediaPicker.prompt = "Select song"
mediaPicker.allowsPickingMultipleItems = false
self.present(mediaPicker, animated: true, completion: nil)
}
}
}

func mediaPicker(_ mediaPicker: MPMediaPickerController, didPickMediaItems mediaItemCollection:MPMediaItemCollection) -> Void {
}

func mediaPickerDidCancel(_ mediaPicker: MPMediaPickerController) {
dismiss(animated: true, completion: nil)
print("MPMediaPickerController - Cancel")
}

最佳答案

请将此添加到您的 info.plist

<key>NSAppleMusicUsageDescription</key>
<string>$(app Name) uses music</string>

它对我有用。

关于ios - MPMediaPickerController 在启动后关闭 (Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49384705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com