我的Storyboard中有两个UIViewConrollers:MainViewController和SecondViewController.当用户点击名为Show Popover的按钮时,我将把SecondViewController显示为弹出框:
//MainViewController override func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) { if segue.identifier == "GoToSecondViewControllerSegue" { var vc = segue.destinationViewController as! SecondViewController var controller = vc.popoverPresentationController if controller != nil { controller?.delegate = self vc.inputTextDelegate = "I'm a popover!" } } } func popoverPresentationControllerDidDismissPopover(popoverPresentationController: UIPopoverPresentationController) { println("done") } func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { return .None }
//SecondViewController @IBAction func dismissPopover(sender: UIButton) { dismissViewControllerAnimated(true,completion: nil) //This dismisses the popover but does not notify the MainViewConroller }
现在我有两个问题:
>当我点击popover内的取消按钮时,它会解除弹出窗口但不会在MainViewController中触发popoverPresentationControllerDidDismissPopover
>我如何将数据从SecondViewController传递到MainViewController,例如UITextView的文本值.