From 9881feb39b792a79e7b20b3f4c0bf0797fbb8b66 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Jun 2020 10:18:42 -0400 Subject: [PATCH] gestures and done possible fix --- JSONCreator_iOS/JSONCreator/AppDelegate.swift | 9 ++++++++- JSONCreator_iOS/JSONCreator/DetailViewController.swift | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/JSONCreator_iOS/JSONCreator/AppDelegate.swift b/JSONCreator_iOS/JSONCreator/AppDelegate.swift index d9fe595..45443d9 100644 --- a/JSONCreator_iOS/JSONCreator/AppDelegate.swift +++ b/JSONCreator_iOS/JSONCreator/AppDelegate.swift @@ -38,6 +38,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele splitViewController.delegate = self splitViewController.preferredDisplayMode = .allVisible + let gr = UILongPressGestureRecognizer(target: self, action: #selector(pasteAndGo)) + splitViewController.view.addGestureRecognizer(gr) + NotificationCenter.default.addObserver(forName: UIViewController.showDetailTargetDidChangeNotification, object: splitViewController, queue: nil) { [weak self] (notification) in if let strongSelf = self, let svc = notification.object as? UISplitViewController { if svc.isCollapsed { @@ -50,6 +53,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele } return true } + + @objc func pasteAndGo() { + (dvc as? DetailViewController)?.textView.text = UIPasteboard.general.string + (dvc as? DetailViewController)?.play() + } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. @@ -93,4 +101,3 @@ extension AppDelegate: UINavigationControllerDelegate { } } } - diff --git a/JSONCreator_iOS/JSONCreator/DetailViewController.swift b/JSONCreator_iOS/JSONCreator/DetailViewController.swift index d4f6b8e..c64c967 100644 --- a/JSONCreator_iOS/JSONCreator/DetailViewController.swift +++ b/JSONCreator_iOS/JSONCreator/DetailViewController.swift @@ -67,7 +67,11 @@ class DetailViewController: UIViewController { let loadObject = MVMCoreLoadObject(pageJSON: page, modulesJSON: jsonObject.optionalDictionaryForKey(KeyModuleMap), requestParameters: nil, dataForPage: nil, delegateObject: nil), viewController.shouldFinishProcessingLoad(loadObject, error: &errorObject!) { let navigation = UINavigationController(rootViewController: viewController) - viewController.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(close)) + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) { + viewController.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.close)) + } + let gr = UILongPressGestureRecognizer(target: self, action: #selector(DetailViewController.close)) + viewController.view.addGestureRecognizer(gr) MVMCoreNavigationHandler.shared()?.present(navigation, animated: true) } else if let errorObject = errorObject { let error = NSError(domain: ErrorDomainNative, code: ErrorCode.initViewController.rawValue, userInfo: [NSLocalizedDescriptionKey: errorObject.messageToLog ?? errorObject.messageToDisplay!])