From 4235dcb58ad9e3c239411815845d3a6b1a587509 Mon Sep 17 00:00:00 2001 From: Naoki Morita Date: Wed, 3 Jun 2015 03:13:27 +0900 Subject: [PATCH 1/3] Update Podfile.lock --- Example/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 0b28895..562279e 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - TouchVisualizer: 4065fa1dfa0999df1741f971ae2905dff143cf89 + TouchVisualizer: 1372f334d452ac8c9bbe9ee18ed4ad9a4b41dadb COCOAPODS: 0.37.2 From bd7695fa82311b7a831385acd35bcf9645cd23e8 Mon Sep 17 00:00:00 2001 From: Naoki Morita Date: Wed, 3 Jun 2015 03:13:48 +0900 Subject: [PATCH 2/3] Separate Visualizer class --- Pod/Classes/Visualizer.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Pod/Classes/Visualizer.swift b/Pod/Classes/Visualizer.swift index 282dd0e..403a26e 100644 --- a/Pod/Classes/Visualizer.swift +++ b/Pod/Classes/Visualizer.swift @@ -38,9 +38,9 @@ final public class Visualizer { touch.removeFromSuperview() } } - - // MARK: - Methods - +} + +extension Visualizer { public class func isEnabled() -> Bool { return sharedInstance.enabled } @@ -50,7 +50,6 @@ final public class Visualizer { } public class func start(config: Configuration) { - let instance = sharedInstance instance.enabled = true instance.config = config @@ -98,7 +97,6 @@ final public class Visualizer { } public func handleEvent(event: UIEvent) { - if event.type != UIEventType.Touches { return } @@ -133,16 +131,18 @@ final public class Visualizer { UIView.animateWithDuration(0.2, delay: 0.0, options: .AllowUserInteraction, animations: { [unowned self] () -> Void in view.alpha = 0.0 view.endTouch() - }, completion: { [unowned self] (finished) -> Void in - view.removeFromSuperview() - self.log(touch) - }); + }, completion: { [unowned self] (finished) -> Void in + view.removeFromSuperview() + self.log(touch) + }); } log(touch) } } } - +} + +extension Visualizer { public func log(touch: UITouch) { if !config.showsLog { return From 69ce7b60cd4c0c3297ef9ee675ff5f8fef8cd1a3 Mon Sep 17 00:00:00 2001 From: Naoki Morita Date: Wed, 3 Jun 2015 03:18:57 +0900 Subject: [PATCH 3/3] Add simulator warning --- Example/Example/ConfigViewController.swift | 2 +- Pod/Classes/Visualizer.swift | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Example/Example/ConfigViewController.swift b/Example/Example/ConfigViewController.swift index 55b6a04..b9c30b5 100644 --- a/Example/Example/ConfigViewController.swift +++ b/Example/Example/ConfigViewController.swift @@ -50,7 +50,7 @@ final class ConfigViewController: UITableViewController { if isSimulator() { let controller = UIAlertController( title: "Warning", - message: "This property doesn't work on simulator because it is not possible to read touch radius on it. Please test it on device.", + message: "This property doesn't work on the simulator because it is not possible to read touch radius on it. Please test it on device.", preferredStyle: .Alert ) controller.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil)) diff --git a/Pod/Classes/Visualizer.swift b/Pod/Classes/Visualizer.swift index 403a26e..9556726 100644 --- a/Pod/Classes/Visualizer.swift +++ b/Pod/Classes/Visualizer.swift @@ -22,6 +22,8 @@ final public class Visualizer { NSNotificationCenter.defaultCenter().addObserver(self, selector: "orientationDidChangeNotification:", name: UIDeviceOrientationDidChangeNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationDidBecomeActiveNotification:", name: UIApplicationDidBecomeActiveNotification, object: nil) UIDevice.currentDevice().beginGeneratingDeviceOrientationNotifications() + + warnIfSimulator() } deinit { @@ -143,6 +145,12 @@ extension Visualizer { } extension Visualizer { + private func warnIfSimulator() { + #if (arch(i386) || arch(x86_64)) && os(iOS) + println("[TouchVisualizer] Warning: TouchRadius doesn't work on the simulator because it is not possible to read touch radius on it.") + #endif + } + public func log(touch: UITouch) { if !config.showsLog { return