Fixes bug where presenting EditCheatViewController would mess up PausePresentationController's layout
This commit is contained in:
parent
9b5357ccd6
commit
15ec9c9f49
@ -116,7 +116,7 @@ private extension CheatsViewController
|
||||
@IBAction func addCheat()
|
||||
{
|
||||
let editCheatViewController = self.makeEditCheatViewController(cheat: nil)
|
||||
self.presentViewController(RSTContainInNavigationController(editCheatViewController), animated: true, completion: nil)
|
||||
editCheatViewController.presentWithPresentingViewController(self)
|
||||
}
|
||||
|
||||
func deleteCheat(cheat: Cheat)
|
||||
@ -231,7 +231,7 @@ extension CheatsViewController
|
||||
|
||||
let editAction = UITableViewRowAction(style: .Normal, title: NSLocalizedString("Edit", comment: "")) { (action, indexPath) in
|
||||
let editCheatViewController = self.makeEditCheatViewController(cheat: cheat)
|
||||
self.presentViewController(RSTContainInNavigationController(editCheatViewController), animated: true, completion: nil)
|
||||
editCheatViewController.presentWithPresentingViewController(self)
|
||||
}
|
||||
|
||||
return [deleteAction, editAction]
|
||||
@ -261,7 +261,8 @@ extension CheatsViewController: UIViewControllerPreviewingDelegate
|
||||
|
||||
func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController)
|
||||
{
|
||||
self.presentViewController(RSTContainInNavigationController(viewControllerToCommit), animated: true, completion: nil)
|
||||
let editCheatViewController = viewControllerToCommit as! EditCheatViewController
|
||||
editCheatViewController.presentWithPresentingViewController(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -163,12 +163,13 @@ extension EditCheatViewController
|
||||
UIPasteboard.generalPasteboard().string = cheat.code
|
||||
}
|
||||
|
||||
let presentingViewController = self.presentingViewController
|
||||
let presentingViewController = self.presentingViewController!
|
||||
|
||||
let editCheatAction = UIPreviewAction(title: NSLocalizedString("Edit", comment: ""), style: .Default) { (action, viewController) in
|
||||
// Delaying until next run loop prevents self from being dismissed immediately
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
presentingViewController?.presentViewController(RSTContainInNavigationController(viewController), animated: true, completion: nil)
|
||||
let editCheatViewController = viewController as! EditCheatViewController
|
||||
editCheatViewController.presentWithPresentingViewController(presentingViewController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +205,18 @@ extension EditCheatViewController
|
||||
}
|
||||
}
|
||||
|
||||
internal extension EditCheatViewController
|
||||
{
|
||||
func presentWithPresentingViewController(presentingViewController: UIViewController)
|
||||
{
|
||||
let navigationController = RSTNavigationController(rootViewController: self)
|
||||
navigationController.modalPresentationStyle = .OverFullScreen // Keeps PausePresentationController active to ensure layout is not messed up
|
||||
navigationController.modalPresentationCapturesStatusBarAppearance = true
|
||||
|
||||
presentingViewController.presentViewController(navigationController, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
private extension EditCheatViewController
|
||||
{
|
||||
@IBAction func updateCheatName(sender: UITextField)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user