Skip to content

Commit

Permalink
Moved logic from pop/pushViewController:animated to -navigationContro…
Browse files Browse the repository at this point in the history
…ller:willShowViewController:animated:. This way when user presses back button quickly enough the transition will happen anyway.
  • Loading branch information
gklka authored and GK committed Oct 12, 2015
1 parent 8d85ea9 commit 543ea09
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 46 deletions.
7 changes: 6 additions & 1 deletion Example/GKFadeNavigationController.xcodeproj/project.pbxproj
Expand Up @@ -247,7 +247,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = GK;
LastUpgradeCheck = 0510;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Gruber Kristóf";
TargetAttributes = {
6003F5AD195388D20070C39A = {
Expand Down Expand Up @@ -456,6 +456,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -521,6 +522,7 @@
INFOPLIST_FILE = "GKFadeNavigationController/GKFadeNavigationController-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -537,6 +539,7 @@
INFOPLIST_FILE = "GKFadeNavigationController/GKFadeNavigationController-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -559,6 +562,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GKFadeNavigationController_Example.app/GKFadeNavigationController_Example";
WRAPPER_EXTENSION = xctest;
Expand All @@ -578,6 +582,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch";
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GKFadeNavigationController_Example.app/GKFadeNavigationController_Example";
WRAPPER_EXTENSION = xctest;
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,10 +23,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -48,15 +48,18 @@
ReferencedContainer = "container:GKFadeNavigationController.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand All @@ -72,10 +75,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Tests/Tests-Info.plist
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
2 changes: 1 addition & 1 deletion GKFadeNavigationController.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "GKFadeNavigationController"
s.version = "0.5.1"
s.version = "0.5.2"
s.summary = "A Navigation Controller which supports animated hiding of the Navigation Bar"
s.description = <<-DESC
This is an example implementation of a `UINavigationController` with support of animated hiding and showing it's Navigation Bar.
Expand Down
21 changes: 4 additions & 17 deletions Pod/Classes/GKFadeNavigationController.m
Expand Up @@ -47,7 +47,7 @@ - (void)viewDidLoad
- (void)setNavigationBarVisibility:(GKFadeNavigationControllerNavigationBarVisibility)navigationBarVisibility animated:(BOOL)animated
{
if (_navigationBarVisibility == navigationBarVisibility) {
NSLog(@"Changing navigaiton bar is not required");
// NSLog(@"Changing navigaiton bar is not required");
return;
}

Expand Down Expand Up @@ -159,29 +159,16 @@ - (UIStatusBarStyle)preferredStatusBarStyle
}
}

#pragma mark - Navigation Controller overrides

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[super pushViewController:viewController animated:animated];
[self updateNavigationBarVisibilityForController:viewController animated:animated];
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
UIViewController *viewController = [super popViewControllerAnimated:animated];
[self updateNavigationBarVisibilityForController:self.topViewController animated:animated];
return viewController;
}

#pragma mark - <UINavigationControllerDelegate>

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[self updateNavigationBarVisibilityForController:viewController animated:animated];

// This code is responsible for adjusting the correct navigation bar style when the user starts a side swipe gesture, but does not finish it.
id<UIViewControllerTransitionCoordinator> transitionCoordinator = navigationController.topViewController.transitionCoordinator;
[transitionCoordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {

if ([context isCancelled]) {
UIViewController *sourceViewController = [context viewControllerForKey:UITransitionContextFromViewControllerKey];
[self updateNavigationBarVisibilityForController:sourceViewController animated:NO];
Expand Down

0 comments on commit 543ea09

Please sign in to comment.