diff --git a/Examples/JGProgressHUD Tests.xcodeproj/project.pbxproj b/Examples/JGProgressHUD Tests.xcodeproj/project.pbxproj index 0775518..824f565 100644 --- a/Examples/JGProgressHUD Tests.xcodeproj/project.pbxproj +++ b/Examples/JGProgressHUD Tests.xcodeproj/project.pbxproj @@ -12,18 +12,20 @@ 6B0687581B776965002C584E /* JGProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B0687511B77692F002C584E /* JGProgressHUD.framework */; }; 6B0687591B776965002C584E /* JGProgressHUD.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6B0687511B77692F002C584E /* JGProgressHUD.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 6B1297821AF124BD00EECA97 /* JGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018D7197BF28100DA4C49 /* JGAppDelegate.m */; }; - 6B1297831AF124BD00EECA97 /* JGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018E0197BF28100DA4C49 /* JGViewController.m */; }; + 6B1297831AF124BD00EECA97 /* JGMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018E0197BF28100DA4C49 /* JGMainViewController.m */; }; 6B1EE4031D2FCEA6000C3CFD /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B1EE4021D2FCEA6000C3CFD /* Launch Screen.storyboard */; }; 6B48F0D31AF12789006EDEB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018D3197BF28100DA4C49 /* main.m */; }; 6B48F0DA1AF12991006EDEB5 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6BC018E2197BF28100DA4C49 /* Images.xcassets */; }; 6B48F0DC1AF129A0006EDEB5 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6BC018D0197BF28100DA4C49 /* InfoPlist.strings */; }; + 6B8A14DB1D55FD1A006DAB93 /* JGDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B8A14DA1D55FD1A006DAB93 /* JGDetailViewController.m */; }; + 6B8A14DC1D55FD1A006DAB93 /* JGDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B8A14DA1D55FD1A006DAB93 /* JGDetailViewController.m */; }; 6BC018C8197BF28100DA4C49 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BC018C7197BF28100DA4C49 /* Foundation.framework */; }; 6BC018CA197BF28100DA4C49 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BC018C9197BF28100DA4C49 /* CoreGraphics.framework */; }; 6BC018CC197BF28100DA4C49 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BC018CB197BF28100DA4C49 /* UIKit.framework */; }; 6BC018D2197BF28100DA4C49 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6BC018D0197BF28100DA4C49 /* InfoPlist.strings */; }; 6BC018D4197BF28100DA4C49 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018D3197BF28100DA4C49 /* main.m */; }; 6BC018D8197BF28100DA4C49 /* JGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018D7197BF28100DA4C49 /* JGAppDelegate.m */; }; - 6BC018E1197BF28100DA4C49 /* JGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018E0197BF28100DA4C49 /* JGViewController.m */; }; + 6BC018E1197BF28100DA4C49 /* JGMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BC018E0197BF28100DA4C49 /* JGMainViewController.m */; }; 6BC018E3197BF28100DA4C49 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6BC018E2197BF28100DA4C49 /* Images.xcassets */; }; /* End PBXBuildFile section */ @@ -90,6 +92,8 @@ 6B0687461B77692F002C584E /* JGProgressHUD.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = JGProgressHUD.xcodeproj; path = ../../JGProgressHUD.xcodeproj; sourceTree = ""; }; 6B1297541AF1245200EECA97 /* JGProgressHUD Tests - Framework.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JGProgressHUD Tests - Framework.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 6B1EE4021D2FCEA6000C3CFD /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; + 6B8A14D91D55FD1A006DAB93 /* JGDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JGDetailViewController.h; sourceTree = ""; }; + 6B8A14DA1D55FD1A006DAB93 /* JGDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JGDetailViewController.m; sourceTree = ""; }; 6BC018C4197BF28100DA4C49 /* JGProgressHUD Tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JGProgressHUD Tests.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 6BC018C7197BF28100DA4C49 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 6BC018C9197BF28100DA4C49 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -99,8 +103,8 @@ 6BC018D5197BF28100DA4C49 /* JGProgressHUD Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JGProgressHUD Tests-Prefix.pch"; sourceTree = ""; }; 6BC018D6197BF28100DA4C49 /* JGAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGAppDelegate.h; sourceTree = ""; }; 6BC018D7197BF28100DA4C49 /* JGAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGAppDelegate.m; sourceTree = ""; }; - 6BC018DF197BF28100DA4C49 /* JGViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGViewController.h; sourceTree = ""; }; - 6BC018E0197BF28100DA4C49 /* JGViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGViewController.m; sourceTree = ""; }; + 6BC018DF197BF28100DA4C49 /* JGMainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGMainViewController.h; sourceTree = ""; }; + 6BC018E0197BF28100DA4C49 /* JGMainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGMainViewController.m; sourceTree = ""; }; 6BC018E2197BF28100DA4C49 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 6BC018E9197BF28100DA4C49 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 6BC01909197C1D0F00DA4C49 /* JGProgressHUD Tests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "JGProgressHUD Tests-Info.plist"; sourceTree = ""; }; @@ -174,8 +178,10 @@ 6B0687461B77692F002C584E /* JGProgressHUD.xcodeproj */, 6BC018D6197BF28100DA4C49 /* JGAppDelegate.h */, 6BC018D7197BF28100DA4C49 /* JGAppDelegate.m */, - 6BC018DF197BF28100DA4C49 /* JGViewController.h */, - 6BC018E0197BF28100DA4C49 /* JGViewController.m */, + 6BC018DF197BF28100DA4C49 /* JGMainViewController.h */, + 6BC018E0197BF28100DA4C49 /* JGMainViewController.m */, + 6B8A14D91D55FD1A006DAB93 /* JGDetailViewController.h */, + 6B8A14DA1D55FD1A006DAB93 /* JGDetailViewController.m */, 6BC018E2197BF28100DA4C49 /* Images.xcassets */, 6B1EE4021D2FCEA6000C3CFD /* Launch Screen.storyboard */, 6BC018CE197BF28100DA4C49 /* Supporting Files */, @@ -329,7 +335,8 @@ files = ( 6B48F0D31AF12789006EDEB5 /* main.m in Sources */, 6B1297821AF124BD00EECA97 /* JGAppDelegate.m in Sources */, - 6B1297831AF124BD00EECA97 /* JGViewController.m in Sources */, + 6B1297831AF124BD00EECA97 /* JGMainViewController.m in Sources */, + 6B8A14DC1D55FD1A006DAB93 /* JGDetailViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -338,8 +345,9 @@ buildActionMask = 2147483647; files = ( 6BC018D4197BF28100DA4C49 /* main.m in Sources */, - 6BC018E1197BF28100DA4C49 /* JGViewController.m in Sources */, + 6BC018E1197BF28100DA4C49 /* JGMainViewController.m in Sources */, 6BC018D8197BF28100DA4C49 /* JGAppDelegate.m in Sources */, + 6B8A14DB1D55FD1A006DAB93 /* JGDetailViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Examples/JGProgressHUD Tests/JGAppDelegate.m b/Examples/JGProgressHUD Tests/JGAppDelegate.m index 8db48b4..cc2e01a 100644 --- a/Examples/JGProgressHUD Tests/JGAppDelegate.m +++ b/Examples/JGProgressHUD Tests/JGAppDelegate.m @@ -7,16 +7,16 @@ // #import "JGAppDelegate.h" -#import "JGViewController.h" +#import "JGMainViewController.h" @implementation JGAppDelegate { - JGViewController *_vc; + JGMainViewController *_vc; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - _vc = [[JGViewController alloc] initWithStyle:UITableViewStyleGrouped]; + _vc = [[JGMainViewController alloc] initWithStyle:UITableViewStyleGrouped]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:_vc]; diff --git a/Examples/JGProgressHUD Tests/JGDetailViewController.h b/Examples/JGProgressHUD Tests/JGDetailViewController.h new file mode 100644 index 0000000..3fcf0cf --- /dev/null +++ b/Examples/JGProgressHUD Tests/JGDetailViewController.h @@ -0,0 +1,13 @@ +// +// JGDetailViewController.h +// JGProgressHUD Tests +// +// Created by Jonas Gessner on 06.08.16. +// Copyright © 2016 Jonas Gessner. All rights reserved. +// + +#import + +@interface JGDetailViewController : UIViewController + +@end diff --git a/Examples/JGProgressHUD Tests/JGDetailViewController.m b/Examples/JGProgressHUD Tests/JGDetailViewController.m new file mode 100644 index 0000000..dda631b --- /dev/null +++ b/Examples/JGProgressHUD Tests/JGDetailViewController.m @@ -0,0 +1,33 @@ +// +// JGDetailViewController.m +// JGProgressHUD Tests +// +// Created by Jonas Gessner on 06.08.16. +// Copyright © 2016 Jonas Gessner. All rights reserved. +// + +#import "JGDetailViewController.h" + +@implementation JGDetailViewController { + UITextField *_textField; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + _textField = [[UITextField alloc] init]; + _textField.borderStyle = UITextBorderStyleRoundedRect; + _textField.placeholder = @"Text field"; + + [self.view addSubview:_textField]; + + self.view.backgroundColor = [UIColor whiteColor]; +} + +- (void)viewDidLayoutSubviews { + [super viewDidLayoutSubviews]; + + _textField.frame = CGRectMake(30.0, (self.view.frame.size.height-25.0)/2.0, self.view.frame.size.width-60.0, 25.0); +} + +@end diff --git a/Examples/JGProgressHUD Tests/JGViewController.h b/Examples/JGProgressHUD Tests/JGMainViewController.h similarity index 66% rename from Examples/JGProgressHUD Tests/JGViewController.h rename to Examples/JGProgressHUD Tests/JGMainViewController.h index b8edb35..48d7ab5 100644 --- a/Examples/JGProgressHUD Tests/JGViewController.h +++ b/Examples/JGProgressHUD Tests/JGMainViewController.h @@ -1,5 +1,5 @@ // -// JGViewController.h +// JGMainViewController.h // JGProgressHUD Tests // // Created by Jonas Gessner on 20.07.14. @@ -8,6 +8,6 @@ #import -@interface JGViewController : UITableViewController +@interface JGMainViewController : UITableViewController @end diff --git a/Examples/JGProgressHUD Tests/JGViewController.m b/Examples/JGProgressHUD Tests/JGMainViewController.m similarity index 96% rename from Examples/JGProgressHUD Tests/JGViewController.m rename to Examples/JGProgressHUD Tests/JGMainViewController.m index 0782db9..21fd06b 100644 --- a/Examples/JGProgressHUD Tests/JGViewController.m +++ b/Examples/JGProgressHUD Tests/JGMainViewController.m @@ -1,12 +1,13 @@ // -// JGViewController.m +// JGMainViewController.m // JGProgressHUD Tests // // Created by Jonas Gessner on 20.07.14. // Copyright (c) 2014 Jonas Gessner. All rights reserved. // -#import "JGViewController.h" +#import "JGMainViewController.h" +#import "JGDetailViewController.h" #if JGProgressHUD_Framework #import @@ -20,7 +21,7 @@ #define iOS7 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) -@interface JGViewController () { +@interface JGMainViewController () { JGProgressHUDStyle _style; JGProgressHUDInteractionType _interaction; BOOL _zoom; @@ -30,7 +31,7 @@ @interface JGViewController () { @end -@implementation JGViewController +@implementation JGMainViewController #pragma mark - JGProgressHUDDelegate @@ -266,7 +267,7 @@ - (void)showTextHUD { HUD.indicatorView = nil; - HUD.textLabel.text = @"Hello, World!"; + HUD.textLabel.text = @"Hello World!"; HUD.position = JGProgressHUDPositionBottomCenter; HUD.marginInsets = (UIEdgeInsets) { .top = 0.0f, @@ -481,12 +482,20 @@ - (void)dismissKeyboard:(UITextField *)t { [t resignFirstResponder]; } +- (void)pushDetailVC { + JGDetailViewController *vc = [[JGDetailViewController alloc] init]; + + [self.navigationController pushViewController:vc animated:YES]; +} + - (void)viewDidLoad { [super viewDidLoad]; self.title = @"JGProgressHUD"; self.tableView.backgroundColor = [UIColor colorWithWhite:0.8f alpha:1.0f]; + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Push VC" style:UIBarButtonItemStylePlain target:self action:@selector(pushDetailVC)]; } diff --git a/JGProgressHUD.podspec b/JGProgressHUD.podspec index 04cf2e3..95063b7 100644 --- a/JGProgressHUD.podspec +++ b/JGProgressHUD.podspec @@ -1,14 +1,14 @@ Pod::Spec.new do |s| s.name = "JGProgressHUD" - s.version = "1.3.6" + s.version = "1.4" 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.6" } + s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.4" } s.source_files = "JGProgressHUD/JGProgressHUD/*.{h,m}" s.resource = "JGProgressHUD/JGProgressHUD/JGProgressHUD Resources.bundle" s.frameworks = "Foundation", "UIKit", "QuartzCore" diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUD.m b/JGProgressHUD/JGProgressHUD/JGProgressHUD.m index d453800..9efbf68 100755 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUD.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUD.m @@ -94,6 +94,10 @@ + (void)keyboardFrameDidChange:(NSNotification *)notification { keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; } ++ (void)keyboardDidHide { + keyboardFrame = CGRectZero; +} + + (CGRect)currentKeyboardFrame { return keyboardFrame; } @@ -105,6 +109,8 @@ + (void)load { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardFrameWillChange:) name:UIKeyboardWillChangeFrameNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardFrameDidChange:) name:UIKeyboardDidChangeFrameNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide) name:UIKeyboardDidHideNotification object:nil]; } } @@ -351,14 +357,16 @@ - (void)applyCornerRadius { } - (void)traitCollectionDidChange:(__unused UITraitCollection *)previousTraitCollection { + [super traitCollectionDidChange:previousTraitCollection]; + if (_presentingFull && _observeTraitCollectionChange) { - [self updateFrame]; + [self updateFrame:YES]; } } -- (void)updateFrame { +- (void)updateFrame:(BOOL)animated { if (self.targetView && !CGRectEqualToRect(self.bounds, self.targetView.bounds)) { - [UIView animateWithDuration:(iPad ? 0.4 : 0.3) delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{ + [UIView animateWithDuration:(animated ? (iPad ? 0.4 : 0.3) : 0.0) delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{ self.frame = [self fullFrameInView:self.targetView]; [self updateHUDAnimated:NO animateIndicatorViewFrame:YES]; } completion:nil]; @@ -410,6 +418,8 @@ - (void)showInView:(UIView *)view animated:(BOOL)animated { // !!!: Use UIApplicationDidChangeStatusBarFrameNotification since UIDeviceOrientationDidChangeNotification still gives the old bounds in orientationChanged selector for self.targetView on iPad unless it is called after a delay. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardFrameChanged:) name:UIKeyboardWillChangeFrameNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardFrameChanged:) name:UIKeyboardDidChangeFrameNotification object:nil]; @@ -566,7 +576,7 @@ - (void)keyboardFrameChanged:(NSNotification *)notification { NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; - UIViewAnimationCurve curve = (UIViewAnimationCurve)[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue]; + UIViewAnimationCurve curve = (UIViewAnimationCurve)[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue]; [UIView animateWithDuration:duration delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionsFromUIViewAnimationCurve(curve) animations:^{ self.frame = frame; @@ -575,7 +585,11 @@ - (void)keyboardFrameChanged:(NSNotification *)notification { } - (void)orientationChanged { - [self updateFrame]; + [self updateFrame:YES]; +} + +- (void)appDidBecomeActive { + [self updateFrame:YES]; } - (void)updateMotionOnHUDView { @@ -878,6 +892,8 @@ - (void)removeObservers { [[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil]; } + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];