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/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 diff --git a/Pod/Classes/Visualizer.swift b/Pod/Classes/Visualizer.swift index 282dd0e..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 { @@ -38,9 +40,9 @@ final public class Visualizer { touch.removeFromSuperview() } } - - // MARK: - Methods - +} + +extension Visualizer { public class func isEnabled() -> Bool { return sharedInstance.enabled } @@ -50,7 +52,6 @@ final public class Visualizer { } public class func start(config: Configuration) { - let instance = sharedInstance instance.enabled = true instance.config = config @@ -98,7 +99,6 @@ final public class Visualizer { } public func handleEvent(event: UIEvent) { - if event.type != UIEventType.Touches { return } @@ -133,15 +133,23 @@ 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 { + 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 {