swiftios8uipopovercontrolleruipickerviewcontroller

UIPopoverController (swift)


trying to get UIPopoverController to show me a uipickerviewcontroller on iPad

    let popOver = UIPopoverController()
    popOver.delegate = self
    popOver.setContentViewController(imagePicker, animated: true)

Error :

*** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController init] is not a valid initializer. You must call -[UIPopoverController initWithContentViewController:].'

Solution

  • Use

    let popOver = UIPopoverController(contentViewController:imagePicker)