I noticed my MediaPickerController was very slow as well (in my current project, using Swift 2.2), even though it was pretty quick earlier in the project (and most of what I have added since has been networking code).
In my code, I was instantiating the MPMediaPickerController only when the user tapped my "Find a song" button. By creating the instance of MPMediaPickerController at the time of the main view loading (I placed it in my class declaration, outside of viewDidLoad), I was (somehow) able to bring that load time back down to less than a second (whereas it sometimes didn't even show up, when I instantiated the MPMediaPickerController at the last possible second).
TLDR: write this:
import UIKit
import MediaPlayer
import MobileCoreServices
class SomeViewController: UIViewController, MPMediaPickerControllerDelegate {
var mediaPickerController = MPMediaPickerController(mediaTypes: .AnyAudio)
func viewDidLoad() {
mediaPickerController.delegate = self
mediaPickerController.prompt = "Select a song that you like"
}
@IBAction func buttonWasTapped(sender: AnyObject) {
self.presentViewController(mediaPickerController, animated: true, completion: nil)
}
}
Instead of this: (notice how I only instantiate mediaPickerController once my button is tapped.
import UIKit
import MediaPlayer
import MobileCoreServices
class SomeViewController: UIViewController, MPMediaPickerControllerDelegate {
func viewDidLoad() {
}
@IBAction func buttonWasTapped(sender: AnyObject) {
var mediaPickerController = MPMediaPickerController(mediaTypes: .AnyAudio)
mediaPickerController.delegate = self
mediaPickerController.prompt = "Select a song that you like"
self.presentViewController(mediaPickerController, animated: true, completion: nil)
}
}