- (BOOL) hasLoaded;
- (void) reloadData;
- (void) unloadData;
+- (UIViewController *) parentOrPresentingViewController;
@end
@interface CyteViewController : UIViewController {
[modal unloadData];
}
+- (UIViewController *) parentOrPresentingViewController {
+ if (UIViewController *parent = [self parentViewController])
+ return parent;
+ if ([self respondsToSelector:@selector(presentingViewController)])
+ return [self presentingViewController];
+ return nil;
+}
+
@end
@implementation CyteViewController
// }}}
- (void) close {
- [[[self navigationController] parentViewController] dismissModalViewControllerAnimated:YES];
+ [[[self navigationController] parentOrPresentingViewController] dismissModalViewControllerAnimated:YES];
}
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
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
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);