Skip to content

Commit

Permalink
Full Split View support, keyboard bug fixes
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
JonasGessner committed Aug 6, 2016
1 parent f1da78d commit eda194e
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 25 deletions.
24 changes: 16 additions & 8 deletions Examples/JGProgressHUD Tests.xcodeproj/project.pbxproj
Expand Up @@ -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 */

Expand Down Expand Up @@ -90,6 +92,8 @@
6B0687461B77692F002C584E /* JGProgressHUD.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = JGProgressHUD.xcodeproj; path = ../../JGProgressHUD.xcodeproj; sourceTree = "<group>"; };
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 = "<group>"; };
6B8A14D91D55FD1A006DAB93 /* JGDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JGDetailViewController.h; sourceTree = "<group>"; };
6B8A14DA1D55FD1A006DAB93 /* JGDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JGDetailViewController.m; sourceTree = "<group>"; };
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; };
Expand All @@ -99,8 +103,8 @@
6BC018D5197BF28100DA4C49 /* JGProgressHUD Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JGProgressHUD Tests-Prefix.pch"; sourceTree = "<group>"; };
6BC018D6197BF28100DA4C49 /* JGAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGAppDelegate.h; sourceTree = "<group>"; };
6BC018D7197BF28100DA4C49 /* JGAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGAppDelegate.m; sourceTree = "<group>"; };
6BC018DF197BF28100DA4C49 /* JGViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGViewController.h; sourceTree = "<group>"; };
6BC018E0197BF28100DA4C49 /* JGViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGViewController.m; sourceTree = "<group>"; };
6BC018DF197BF28100DA4C49 /* JGMainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JGMainViewController.h; sourceTree = "<group>"; };
6BC018E0197BF28100DA4C49 /* JGMainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JGMainViewController.m; sourceTree = "<group>"; };
6BC018E2197BF28100DA4C49 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
6 changes: 3 additions & 3 deletions Examples/JGProgressHUD Tests/JGAppDelegate.m
Expand Up @@ -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];

Expand Down
13 changes: 13 additions & 0 deletions 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 <UIKit/UIKit.h>

@interface JGDetailViewController : UIViewController

@end
33 changes: 33 additions & 0 deletions 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
@@ -1,5 +1,5 @@
//
// JGViewController.h
// JGMainViewController.h
// JGProgressHUD Tests
//
// Created by Jonas Gessner on 20.07.14.
Expand All @@ -8,6 +8,6 @@

#import <UIKit/UIKit.h>

@interface JGViewController : UITableViewController
@interface JGMainViewController : UITableViewController

@end
@@ -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 <JGProgressHUD/JGProgressHUD.h>
Expand All @@ -20,7 +21,7 @@

#define iOS7 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0)

@interface JGViewController () <JGProgressHUDDelegate> {
@interface JGMainViewController () <JGProgressHUDDelegate> {
JGProgressHUDStyle _style;
JGProgressHUDInteractionType _interaction;
BOOL _zoom;
Expand All @@ -30,7 +31,7 @@ @interface JGViewController () <JGProgressHUDDelegate> {

@end

@implementation JGViewController
@implementation JGMainViewController

#pragma mark - JGProgressHUDDelegate

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)];
}


Expand Down
4 changes: 2 additions & 2 deletions 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"
Expand Down
26 changes: 21 additions & 5 deletions JGProgressHUD/JGProgressHUD/JGProgressHUD.m
Expand Up @@ -94,6 +94,10 @@ + (void)keyboardFrameDidChange:(NSNotification *)notification {
keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
}

+ (void)keyboardDidHide {
keyboardFrame = CGRectZero;
}

+ (CGRect)currentKeyboardFrame {
return keyboardFrame;
}
Expand All @@ -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];
}
}

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand All @@ -575,7 +585,11 @@ - (void)keyboardFrameChanged:(NSNotification *)notification {
}

- (void)orientationChanged {
[self updateFrame];
[self updateFrame:YES];
}

- (void)appDidBecomeActive {
[self updateFrame:YES];
}

- (void)updateMotionOnHUDView {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit eda194e

Please sign in to comment.