0

I have my application set up to segue to another NewHelpRequestViewController by clicking on the last cell in an array. What I am wanting to do is open up the view controller as a popover instead.

class MainViewController : UITableViewController, UIPopoverPresentationControllerDelegate {


override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
    if indexPath.row == questionViewCellArray.count-1 {
        self.performSegue(withIdentifier: "showNewRequest" , sender : self)
    }
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "showNewRequest" {
        if let controller = segue.destination as? NewHelpRequestViewController {
            controller.popoverPresentationController!.delegate = self
            controller.preferredContentSize = CGSize(width: 200, height: 300)
        }
    }
}

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
    return .none
}

Right now it will open NewHelpRequestViewController without any issues or errors. I linked what relevant code I could. If I need to show anything else, please let me know.

I should also mention that this is for an iphone.

icestorm0806
  • 691
  • 1
  • 9
  • 20
  • PopOver isn't possible on portrait – excitedmicrobe Dec 09 '18 at 08:06
  • Are you trying to create an *iPad* style popover on an *iPhone*? Under normal circumstances you can't - iOS by default makes it fullscreen. (It is possible though, I used to have code that did it but went in another direction and lost it.) Or is there some other issue? Would either "faking" a popover or using a child view controller solve your issue? –  Dec 09 '18 at 09:12
  • If the issue is the former, here's a 4 year old link (I'm guessing Swift 1) that may help: https://www.richardallen.me/2014/11/28/popovers.html –  Dec 09 '18 at 09:14

0 Answers0