关闭Popover时,如何保存当前状态?

时间:2017-03-30 06:19:35

标签: ios iphone swift xcode popover

通过Storyboard segue,我制作了一个Popover View。在popover viewcontroller中,有两个SWITCH(On / OFF)。一切都好。但是在关闭popover viewcontroller之后,当重新调用popover视图时,Popover的状态是默认状态。也就是说,SWITCH每次都打开。如何保存更改后的状态(SWITCH为OFF,如果已完成)。

这可能是PopOver的代码

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "noticePopover" {
        let popoverViewController = segue.destination
        popoverViewController.popoverPresentationController?.delegate = self
        UIView.animate(withDuration: 0.5, animations: {
            self.view.alpha = 0.5
        })

        segue.destination.popoverPresentationController?.backgroundColor = inspotPointColor
    }
}

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
    return UIModalPresentationStyle.none
}
func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
    print("popoverPresentationControllerDidDismissPopover")
    UIView.animate(withDuration: 0.2, animations: {
        self.view.alpha = 1.0
    })
}

我已经搜索了这个问题,但我找不到解决方案。请告诉我你的好意。

0 个答案:

没有答案