From 2fcb1d49a0be54a0d43a4984e6e50e0a2d8d77f9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 21 Mar 2011 03:35:20 -0700 Subject: [PATCH] Work around stupid 2.x UINavigationController behavior. --- MobileCydia.mm | 22 ++++++++++++++++++++++ iPhonePrivate.h | 1 + 2 files changed, 23 insertions(+) diff --git a/MobileCydia.mm b/MobileCydia.mm index 41cc4e78..dd7b14ac 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6747,6 +6747,20 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @implementation CYTabBarController +- (void) didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + + // presenting a UINavigationController on 2.x does not update its transitionView + // it thereby will not allow its topViewController to be unloaded by memory pressure + if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) { + UIViewController *selected([self selectedViewController]); + for (UINavigationController *controller in [self viewControllers]) + if (controller != selected) + if (UIViewController *top = [controller topViewController]) + [top unloadView]; + } +} + - (void) setUnselectedViewController:(UIViewController *)transient { if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) { if (transient != nil) { @@ -6786,6 +6800,14 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([self unselectedViewController]) [self setUnselectedViewController:nil]; + + // presenting a UINavigationController on 2.x does not update its transitionView + // if this view was unloaded, the tranitionView may currently be presenting nothing + if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) { + UINavigationController *navigation((UINavigationController *) viewController); + [navigation pushViewController:[[[UIViewController alloc] init] autorelease] animated:NO]; + [navigation popViewControllerAnimated:NO]; + } } - (NSArray *) navigationURLCollection { diff --git a/iPhonePrivate.h b/iPhonePrivate.h index 788c3c51..8cc997a1 100644 --- a/iPhonePrivate.h +++ b/iPhonePrivate.h @@ -296,6 +296,7 @@ typedef enum { @interface UIViewController (Apple) - (void) _updateLayoutForStatusBarAndInterfaceOrientation; +- (void) unloadView; @end @interface UIWindow (Apple) -- 2.45.2