summaryrefslogtreecommitdiff
path: root/platform/ios/Classes
diff options
context:
space:
mode:
authorPaul Gardiner <paul.gardiner@artifex.com>2014-01-10 11:58:09 +0000
committerPaul Gardiner <paul.gardiner@artifex.com>2014-01-10 14:57:23 +0000
commit161709a8b8d5036ec8d33dc95620310161835dbd (patch)
tree094a9082d074a2a118db65441fbe61435982f615 /platform/ios/Classes
parentbf2aa9521b016d849eb4e88be3281fa84b5ab317 (diff)
downloadmupdf-161709a8b8d5036ec8d33dc95620310161835dbd.tar.xz
iOS: on iPhone use custom buttons to accommodate shortage of space
Otherwise, in portrait mode, there isn’t enough room for all five buttons and some are not displayed.
Diffstat (limited to 'platform/ios/Classes')
-rw-r--r--platform/ios/Classes/MuDocumentController.m13
-rw-r--r--platform/ios/Classes/TapImage.h5
-rw-r--r--platform/ios/Classes/TapImage.m18
3 files changed, 35 insertions, 1 deletions
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 <TapImage.h>
#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 <UIKit/UIKit.h>
+
+@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