diff options
author | Grant Paul <chpwn@chpwn.com> | 2011-02-13 15:25:30 -0800 |
---|---|---|
committer | Grant Paul <chpwn@chpwn.com> | 2011-02-13 15:25:30 -0800 |
commit | 9f99f3daceff1725ca3a8872ad5ff3a625e8f593 (patch) | |
tree | 07b0a2df632c135bb4ef93ad2f70a71295d43085 /MobileCydia.mm | |
parent | efa53fa95b1408425c69f1e2158c7b53d99c11b6 (diff) |
Horrible, awful, ugly, nasty, evil, terrible, scary, screwed up, and despicable hack to fix the "transientViewController" issues on CYTabBar.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 561aebc..b6aed53 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6283,6 +6283,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { /* Cydia Tab Bar Controller {{{ */ @interface CYTabBarController : UITabBarController < + UITabBarControllerDelegate, ProgressDelegate > { _transient Database *database_; @@ -6294,6 +6295,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { _transient NSObject<CydiaDelegate> *updatedelegate_; id root_; + UIViewController *remembered_; + _transient UIViewController *transient_; } - (NSArray *) navigationURLCollection; @@ -6306,6 +6309,37 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @implementation CYTabBarController +- (void) setUnselectedViewController:(UIViewController *)transient { + NSMutableArray *controllers = [[self viewControllers] mutableCopy]; + if (transient != nil) { + if (transient_ == nil) + remembered_ = [[controllers objectAtIndex:0] retain]; + transient_ = transient; + [transient_ setTabBarItem:[remembered_ tabBarItem]]; + [controllers replaceObjectAtIndex:0 withObject:transient_]; + [self setSelectedIndex:0]; + [self setViewControllers:controllers]; + [self concealTabBarSelection]; + } else if (remembered_ != nil) { + [remembered_ setTabBarItem:[transient_ tabBarItem]]; + transient_ = transient; + [controllers replaceObjectAtIndex:0 withObject:remembered_]; + [remembered_ release]; + remembered_ = nil; + [self setViewControllers:controllers]; + [self revealTabBarSelection]; + } +} + +- (UIViewController *) unselectedViewController { + return transient_; +} + +- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { + if ([self unselectedViewController]) + [self setUnselectedViewController:nil]; +} + - (NSArray *) navigationURLCollection { NSMutableArray *items([NSMutableArray array]); @@ -6323,7 +6357,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { for (CYViewController *controller in [self viewControllers]) [controller reloadData]; - [(CYNavigationController *)[self transientViewController] reloadData]; + [(CYNavigationController *)[self unselectedViewController] reloadData]; } - (void) dealloc { @@ -6336,6 +6370,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (id) initWithDatabase:(Database *)database { if ((self = [super init]) != nil) { database_ = database; + [self setDelegate:self]; [[self view] setAutoresizingMask:UIViewAutoresizingFlexibleBoth]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; @@ -8983,7 +9018,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if (page != nil) { CYNavigationController *nav = [[[CYNavigationController alloc] init] autorelease]; [nav setViewControllers:[NSArray arrayWithObject:page]]; - [tabbar_ setTransientViewController:nav]; + [tabbar_ setUnselectedViewController:nav]; } return page != nil; @@ -9048,7 +9083,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) setupViewControllers { tabbar_ = [[CYTabBarController alloc] initWithDatabase:database_]; - [tabbar_ setDelegate:self]; NSMutableArray *items([NSMutableArray arrayWithObjects: [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:0] autorelease], |