#import "RVPage.h"
+@interface NSObject (UICaboodleRVBook)
+- (float) widthForButtonContents:(float)width;
+@end
+
+@implementation NSObject (UICaboodleRVBook)
+
+- (float) widthForButtonContents:(float)width {
+ return width;
+}
+
+@end
+
+@interface UIImage (UICaboodleRVBook)
+- (float) widthForButtonContents:(float)width;
+@end
+
+@implementation UIImage (UICaboodleRVBook)
+
+- (float) widthForButtonContents:(float)width {
+ return [self size].width + 8;
+}
+
+@end
+
+@interface RVNavigationBar : UINavigationBar {
+}
+
+- (id) createButtonWithContents:(id)contents width:(float)width barStyle:(int)barStyle buttonStyle:(int)style isRight:(BOOL)right;
+@end
+
+@implementation RVNavigationBar
+
+- (id) createButtonWithContents:(id)contents width:(float)width barStyle:(int)barStyle buttonStyle:(int)style isRight:(BOOL)right {
+ float adjust = [contents widthForButtonContents:width];
+ NSLog(@"cc:%@:%g:%g", contents, width, adjust);
+ width = adjust;
+ return [super createButtonWithContents:contents width:width barStyle:barStyle buttonStyle:style isRight:right];
+}
+
+@end
+
@implementation RVBook
- (void) dealloc {
CGSize navsize = [UINavigationBar defaultSize];
CGRect navrect = {{0, 0}, navsize};
- navbar_ = [[UINavigationBar alloc] initWithFrame:navrect];
+ navbar_ = [[RVNavigationBar alloc] initWithFrame:navrect];
[self addSubview:navbar_];
[navbar_ setBarStyle:0];
[navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO];
}
-- (void) setTitle:(NSString *)title forPage:(RVPage *)page {
+- (void) setBackButtonTitle:(NSString *)title forPage:(RVPage *)page {
if ([pages_ count] == 0 || page != [pages_ lastObject])
return;
UINavigationItem *navitem = [navbar_ topItem];
- [navitem setTitle:title];
+ [navitem setBackButtonTitle:title];
}
-- (void) setBackButtonTitle:(NSString *)title forPage:(RVPage *)page {
+- (void) reloadTitleForPage:(RVPage *)page {
if ([pages_ count] == 0 || page != [pages_ lastObject])
return;
UINavigationItem *navitem = [navbar_ topItem];
- [navitem setBackButtonTitle:title];
+ NSString *title = [self getTitleForPage:page];
+ [navitem setTitle:title];
}
- (void) reloadButtonsForPage:(RVPage *)page {