From 19f2d77f02510fd14320166f45a33e6aa77cb396 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 23 Dec 2011 22:41:50 -0800 Subject: [PATCH] "Oh, my God... they killed parentViewController!" --- CyteKit/ViewController.h | 1 + CyteKit/ViewController.mm | 8 ++++++++ CyteKit/WebViewController.mm | 4 ++-- MobileCydia.mm | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CyteKit/ViewController.h b/CyteKit/ViewController.h index f707ba28..6cbff248 100644 --- a/CyteKit/ViewController.h +++ b/CyteKit/ViewController.h @@ -48,6 +48,7 @@ - (BOOL) hasLoaded; - (void) reloadData; - (void) unloadData; +- (UIViewController *) parentOrPresentingViewController; @end @interface CyteViewController : UIViewController { diff --git a/CyteKit/ViewController.mm b/CyteKit/ViewController.mm index a25da53e..3d22f60a 100644 --- a/CyteKit/ViewController.mm +++ b/CyteKit/ViewController.mm @@ -59,6 +59,14 @@ extern bool IsWildcat_; [modal unloadData]; } +- (UIViewController *) parentOrPresentingViewController { + if (UIViewController *parent = [self parentViewController]) + return parent; + if ([self respondsToSelector:@selector(presentingViewController)]) + return [self presentingViewController]; + return nil; +} + @end @implementation CyteViewController diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 25e9aebb..cfe01f70 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -630,7 +630,7 @@ float CYScrollViewDecelerationRateNormal; // }}} - (void) close { - [[[self navigationController] parentViewController] dismissModalViewControllerAnimated:YES]; + [[[self navigationController] parentOrPresentingViewController] dismissModalViewControllerAnimated:YES]; } - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button { @@ -714,7 +714,7 @@ float CYScrollViewDecelerationRateNormal; return nil; if (UINavigationController *navigation = [self navigationController]) - if ([[navigation parentViewController] modalViewController] == navigation) + if ([[navigation parentOrPresentingViewController] modalViewController] == navigation) return [[[UIBarButtonItem alloc] initWithTitle:UCLocalize("CLOSE") style:UIBarButtonItemStylePlain diff --git a/MobileCydia.mm b/MobileCydia.mm index 58a380ef..a011b9e0 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6209,8 +6209,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { CGRect kbframe = CGRectMake(round(center.x - bounds.size.width / 2.0), round(center.y - bounds.size.height / 2.0), bounds.size.width, bounds.size.height); UIViewController *base = self; - while ([base parentViewController] != nil) - base = [base parentViewController]; + while ([base parentOrPresentingViewController] != nil) + base = [base parentOrPresentingViewController]; CGRect viewframe = [[base view] convertRect:[list_ frame] fromView:[list_ superview]]; CGRect intersection = CGRectIntersection(viewframe, kbframe); -- 2.45.2