Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #50 from morizotter/simulator-use
Browse files Browse the repository at this point in the history
Simulator use
  • Loading branch information
morizotter committed Jun 2, 2015
2 parents 46860d1 + 69ce7b6 commit ab0a626
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Example/Example/ConfigViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
TouchVisualizer: 4065fa1dfa0999df1741f971ae2905dff143cf89
TouchVisualizer: 1372f334d452ac8c9bbe9ee18ed4ad9a4b41dadb

COCOAPODS: 0.37.2
26 changes: 17 additions & 9 deletions Pod/Classes/Visualizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -38,9 +40,9 @@ final public class Visualizer {
touch.removeFromSuperview()
}
}
// MARK: - Methods
}

extension Visualizer {
public class func isEnabled() -> Bool {
return sharedInstance.enabled
}
Expand All @@ -50,7 +52,6 @@ final public class Visualizer {
}

public class func start(config: Configuration) {

let instance = sharedInstance
instance.enabled = true
instance.config = config
Expand Down Expand Up @@ -98,7 +99,6 @@ final public class Visualizer {
}

public func handleEvent(event: UIEvent) {

if event.type != UIEventType.Touches {
return
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ab0a626

Please sign in to comment.