From 161709a8b8d5036ec8d33dc95620310161835dbd Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Fri, 10 Jan 2014 11:58:09 +0000 Subject: iOS: on iPhone use custom buttons to accommodate shortage of space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, in portrait mode, there isn’t enough room for all five buttons and some are not displayed. --- platform/ios/Classes/MuDocumentController.m | 13 ++++++++++++- platform/ios/Classes/TapImage.h | 5 +++++ platform/ios/Classes/TapImage.m | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 platform/ios/Classes/TapImage.h create mode 100644 platform/ios/Classes/TapImage.m (limited to 'platform/ios/Classes') diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 25c5dfab..962403ec 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -1,5 +1,6 @@ #include "common.h" +#import #import "MuPageViewNormal.h" #import "MuPageViewReflow.h" #import "MuDocumentController.h" @@ -152,7 +153,17 @@ static void saveDoc(char *current_path, fz_document *doc) - (UIBarButtonItem *) resourceBasedButton:(NSString *)resource withAction:(SEL)selector { - return [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:resource ofType:@"png"]] style:UIBarButtonItemStylePlain target:self action:selector]; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + return [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:resource ofType:@"png"]] style:UIBarButtonItemStylePlain target:self action:selector]; + } + else + { + UIView *iv = [[TapImage alloc] initWithResource:resource target:self action:selector]; + UIBarButtonItem *ib = [[UIBarButtonItem alloc] initWithCustomView:iv]; + [iv release]; + return ib; + } } - (void) addMainMenuButtons diff --git a/platform/ios/Classes/TapImage.h b/platform/ios/Classes/TapImage.h new file mode 100644 index 00000000..43234474 --- /dev/null +++ b/platform/ios/Classes/TapImage.h @@ -0,0 +1,5 @@ +#import + +@interface TapImage : UIImageView +- (id)initWithResource:(NSString *)resource target:(id)obj action:(SEL)selector; +@end diff --git a/platform/ios/Classes/TapImage.m b/platform/ios/Classes/TapImage.m new file mode 100644 index 00000000..e02e8b7a --- /dev/null +++ b/platform/ios/Classes/TapImage.m @@ -0,0 +1,18 @@ +#import "TapImage.h" + +@implementation TapImage + +- (id)initWithResource:(NSString *)resource target:(id)targ action:(SEL)selector +{ + UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:resource ofType:@"png"]]; + self = [super initWithImage:image]; + if (self) + { + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:targ action:selector]; + [self addGestureRecognizer:tap]; + [tap release]; + } + return self; +} + +@end -- cgit v1.2.3