diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-03 13:09:55 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-07 02:41:35 -0800 |
commit | e6124cb6861825f588b0cf7be198ea35b5b730ba (patch) | |
tree | 9441a0174cecbb1681052b1a59ad70ef7fd7ac90 /CyteKit | |
parent | 6ffdaae37da1b4c63d067805fc279ef5cbe847e5 (diff) |
Provide -[CyteWebViewController leftButton] API.
Diffstat (limited to 'CyteKit')
-rw-r--r-- | CyteKit/WebViewController.h | 3 | ||||
-rw-r--r-- | CyteKit/WebViewController.mm | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index db40a1c..c1ec1ee 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -128,6 +128,9 @@ - (UIBarButtonItem *) customButton; - (UIBarButtonItem *) rightButton; +- (void) applyLeftButton; +- (UIBarButtonItem *) leftButton; + - (void) _didStartLoading; - (void) _didFinishLoading; diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index b59d830..a750278 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -611,6 +611,27 @@ float CYScrollViewDecelerationRateNormal; ] autorelease]; } +- (UIBarButtonItem *) leftButton { + UINavigationItem *item([self navigationItem]); + if ([item backBarButtonItem] != nil && ![item hidesBackButton]) + return nil; + + if (UINavigationController *navigation = [self navigationController]) + if ([[navigation parentViewController] modalViewController] == navigation) + return [[[UIBarButtonItem alloc] + initWithTitle:UCLocalize("CLOSE") + style:UIBarButtonItemStylePlain + target:self + action:@selector(close) + ] autorelease]; + + return nil; +} + +- (void) applyLeftButton { + [[self navigationItem] setLeftBarButtonItem:[self leftButton]]; +} + - (UIBarButtonItem *) rightButton { return reloaditem_; } @@ -784,6 +805,8 @@ float CYScrollViewDecelerationRateNormal; UITableView *table([[[UITableView alloc] initWithFrame:bounds style:UITableViewStyleGrouped] autorelease]); [webview_ insertSubview:table atIndex:0]; + [self applyLeftButton]; + [table setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; @@ -881,6 +904,7 @@ float CYScrollViewDecelerationRateNormal; - (void) setHidesBackButton:(bool)value { [[self navigationItem] setHidesBackButton:value]; + [self applyLeftButton]; } - (void) setHidesBackButtonByNumber:(NSNumber *)value { |