diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2014-01-10 11:58:09 +0000 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2014-01-10 14:57:23 +0000 |
commit | 161709a8b8d5036ec8d33dc95620310161835dbd (patch) | |
tree | 094a9082d074a2a118db65441fbe61435982f615 /platform/ios | |
parent | bf2aa9521b016d849eb4e88be3281fa84b5ab317 (diff) | |
download | mupdf-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')
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 13 | ||||
-rw-r--r-- | platform/ios/Classes/TapImage.h | 5 | ||||
-rw-r--r-- | platform/ios/Classes/TapImage.m | 18 | ||||
-rw-r--r-- | platform/ios/MuPDF.xcodeproj/project.pbxproj | 6 |
4 files changed, 41 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 diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj index cf2c1544..492ea205 100644 --- a/platform/ios/MuPDF.xcodeproj/project.pbxproj +++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ DAD47D301832615900E173A0 /* ic_underline.png in Resources */ = {isa = PBXBuildFile; fileRef = DAD47D2D1832615900E173A0 /* ic_underline.png */; }; DAD72802183E53F0005C14FA /* MuAnnotSelectView.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD72801183E53F0005C14FA /* MuAnnotSelectView.m */; }; DAD72804183E6F33005C14FA /* ic_trash.png in Resources */ = {isa = PBXBuildFile; fileRef = DAD72803183E6F33005C14FA /* ic_trash.png */; }; + DAF81D5B18800D1800B0F028 /* TapImage.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF81D5A18800D1800B0F028 /* TapImage.m */; }; DAFF997B187C12430081C756 /* MuChoiceFieldController.m in Sources */ = {isa = PBXBuildFile; fileRef = DAFF9979187C12430081C756 /* MuChoiceFieldController.m */; }; DAFF997C187C12430081C756 /* MuChoiceFieldController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DAFF997A187C12430081C756 /* MuChoiceFieldController.xib */; }; /* End PBXBuildFile section */ @@ -148,6 +149,8 @@ DAD72801183E53F0005C14FA /* MuAnnotSelectView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuAnnotSelectView.m; path = Classes/MuAnnotSelectView.m; sourceTree = "<group>"; }; DAD72803183E6F33005C14FA /* ic_trash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_trash.png; path = "../android/res/drawable-ldpi/ic_trash.png"; sourceTree = "<group>"; }; DADD8D6917EB24C000C49E0B /* MuPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuPageView.h; path = Classes/MuPageView.h; sourceTree = "<group>"; }; + DAF81D5918800D1800B0F028 /* TapImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TapImage.h; path = Classes/TapImage.h; sourceTree = "<group>"; }; + DAF81D5A18800D1800B0F028 /* TapImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TapImage.m; path = Classes/TapImage.m; sourceTree = "<group>"; }; DAFF9978187C12430081C756 /* MuChoiceFieldController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuChoiceFieldController.h; path = Classes/MuChoiceFieldController.h; sourceTree = "<group>"; }; DAFF9979187C12430081C756 /* MuChoiceFieldController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuChoiceFieldController.m; path = Classes/MuChoiceFieldController.m; sourceTree = "<group>"; }; DAFF997A187C12430081C756 /* MuChoiceFieldController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MuChoiceFieldController.xib; path = Classes/MuChoiceFieldController.xib; sourceTree = "<group>"; }; @@ -285,6 +288,8 @@ DAFF9978187C12430081C756 /* MuChoiceFieldController.h */, DAFF9979187C12430081C756 /* MuChoiceFieldController.m */, DAFF997A187C12430081C756 /* MuChoiceFieldController.xib */, + DAF81D5918800D1800B0F028 /* TapImage.h */, + DAF81D5A18800D1800B0F028 /* TapImage.m */, ); name = Classes; sourceTree = "<group>"; @@ -427,6 +432,7 @@ files = ( DAA6E56F17F03F96002B1E4E /* MuPageViewReflow.m in Sources */, DA1C68AB17E86A500061F586 /* MuLibraryController.m in Sources */, + DAF81D5B18800D1800B0F028 /* TapImage.m in Sources */, DA1C68AD17E86A500061F586 /* MuOutlineController.m in Sources */, DA1C68AF17E86A500061F586 /* MuHitView.m in Sources */, DA1C68B117E86A500061F586 /* MuPageViewNormal.m in Sources */, |