Skip to content

Commit

Permalink
Fixed crash on iOS 7
Browse files Browse the repository at this point in the history
Fixes #60
  • Loading branch information
JonasGessner committed Jul 8, 2016
1 parent a474ab7 commit 7a33473
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions JGProgressHUD.podspec
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|

s.name = "JGProgressHUD"
s.version = "1.3.4"
s.version = "1.3.5"
s.summary = "Powerful and modern progress HUD for iOS."
s.homepage = "https://github.com/JonasGessner/JGProgressHUD"
s.license = { :type => "MIT", :file => "LICENSE.txt" }
s.author = "Jonas Gessner"
s.social_media_url = "http://twitter.com/JonasGessner"
s.platform = :ios, "6.0"
s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.3.4" }
s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.3.5" }
s.source_files = "JGProgressHUD/JGProgressHUD/*.{h,m}"
s.resource = "JGProgressHUD/JGProgressHUD/JGProgressHUD Resources.bundle"
s.frameworks = "Foundation", "UIKit", "QuartzCore"
Expand Down
4 changes: 2 additions & 2 deletions JGProgressHUD/JGProgressHUD/JGProgressHUD-Defines.h
Expand Up @@ -60,9 +60,9 @@ typedef NS_ENUM(NSUInteger, JGProgressHUDInteractionType) {
Parallax Modes.
*/
typedef NS_ENUM(NSUInteger, JGProgressHUDParallaxMode) {
/** Follows the device setting for parallax. If "Reduce Motion" is enabled, no parallax effect is added to the HUD, if "Reduce Motion" is disabled the HUD will have a parallax effect. */
/** Follows the device setting for parallax. If "Reduce Motion" is enabled, no parallax effect is added to the HUD, if "Reduce Motion" is disabled the HUD will have a parallax effect. This behaviour is only supported on iOS 8 and higher. */
JGProgressHUDParallaxModeDevice = 0,
/** Always adds a parallax effect to the HUD. */
/** Always adds a parallax effect to the HUD. Parallax is only supported on iOS 7 and higher. */
JGProgressHUDParallaxModeAlwaysOn,
/** Never adds a parallax effect to the HUD. */
JGProgressHUDParallaxModeAlwaysOff
Expand Down
14 changes: 8 additions & 6 deletions JGProgressHUD/JGProgressHUD/JGProgressHUD.m
Expand Up @@ -552,7 +552,9 @@ - (void)orientationChanged {

- (void)updateMotionOnHUDView {
if (iOS7) {
BOOL wantsParallax = ((self.parallaxMode == JGProgressHUDParallaxModeDevice && !UIAccessibilityIsReduceMotionEnabled()) || self.parallaxMode == JGProgressHUDParallaxModeAlwaysOn);
BOOL reduceMotionEnabled = (iOS8 && UIAccessibilityIsReduceMotionEnabled());

BOOL wantsParallax = ((self.parallaxMode == JGProgressHUDParallaxModeDevice && !reduceMotionEnabled) || self.parallaxMode == JGProgressHUDParallaxModeAlwaysOn);
BOOL hasParallax = (_HUDViewHost.motionEffects.count > 0);

if (wantsParallax == hasParallax) {
Expand Down Expand Up @@ -597,11 +599,9 @@ - (BOOL)isVisible {

- (UIView *)HUDView {
if (!_HUDView) {
if (iOS7) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateMotionOnHUDView) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
}

if (iOS8) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateMotionOnHUDView) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];

UIBlurEffectStyle effect = 0;

if (self.style == JGProgressHUDStyleDark) {
Expand Down Expand Up @@ -846,7 +846,9 @@ - (void)dealloc {
}

- (void)removeObservers {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
if (iOS8) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
}

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil];

Expand Down

0 comments on commit 7a33473

Please sign in to comment.