summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Holgate <matt@emobix.co.uk>2014-07-07 12:30:25 +0100
committerMatt Holgate <matt@emobix.co.uk>2014-07-07 12:30:25 +0100
commit184c4f75f9697877c7a8f1d512bef23f557b0c04 (patch)
treef4906f0e1397fbeced24240d4efb755f54ab00e4
parent0144342e08e2bbd0be9a7ae562a7053be12dcb1e (diff)
downloadmupdf-184c4f75f9697877c7a8f1d512bef23f557b0c04.tar.xz
Fix disabled state of bar buttons on iPhone/iPod Touch.
Previously on iOS 7, bar buttons didn't change visually when disabled. Also improves the look and feel - the buttons are now tinted in the highlighted state rather than showing a grey background. On iOS 7, the iPhone/iPad buttons style match. Tested on iOS 6 iPad/iPod and iOS 7 iPad/iPod.
-rw-r--r--platform/ios/Classes/MuDocumentController.m14
-rw-r--r--platform/ios/Classes/TapImage.h9
-rw-r--r--platform/ios/Classes/TapImage.m37
-rw-r--r--platform/ios/MuPDF.xcodeproj/project.pbxproj6
4 files changed, 9 insertions, 57 deletions
diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m
index c9ac2e66..36f2c867 100644
--- a/platform/ios/Classes/MuDocumentController.m
+++ b/platform/ios/Classes/MuDocumentController.m
@@ -1,6 +1,5 @@
#include "common.h"
-#import <TapImage.h>
#import "MuPageViewNormal.h"
#import "MuPageViewReflow.h"
#import "MuDocumentController.h"
@@ -165,10 +164,15 @@ static void saveDoc(char *current_path, fz_document *doc)
}
else
{
- UIView *iv = [[TapImage alloc] initWithResource:resource target:self action:selector];
- UIBarButtonItem *ib = [[UIBarButtonItem alloc] initWithCustomView:iv];
- [iv release];
- return ib;
+ UIView *buttonView;
+ BOOL iOS7Style = ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f);
+ UIButton *button = [UIButton buttonWithType:iOS7Style ? UIButtonTypeSystem : UIButtonTypeCustom];
+ [button setImage:[UIImage imageNamed:resource] forState:UIControlStateNormal];
+ [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
+ [button sizeToFit];
+ buttonView = button;
+
+ return [[UIBarButtonItem alloc] initWithCustomView:buttonView];
}
}
diff --git a/platform/ios/Classes/TapImage.h b/platform/ios/Classes/TapImage.h
deleted file mode 100644
index af31ea5f..00000000
--- a/platform/ios/Classes/TapImage.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface TapImage : UIImageView
-{
- id target;
- SEL action;
-}
-- (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
deleted file mode 100644
index 1a43813e..00000000
--- a/platform/ios/Classes/TapImage.m
+++ /dev/null
@@ -1,37 +0,0 @@
-#import "TapImage.h"
-
-static const NSTimeInterval TapDuration = 0.05;
-
-@implementation TapImage
-
-- (id)initWithResource:(NSString *)resource target:(id)targ action:(SEL)selector
-{
- UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:resource ofType:@"png"]];
- if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
- image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
- self = [super initWithImage:image];
- if (self)
- {
- target = targ;
- action = selector;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap)];
- [self addGestureRecognizer:tap];
- [tap release];
- }
- return self;
-}
-
-- (void) onTap
-{
- [UIView animateWithDuration:TapDuration animations:^{
- self.backgroundColor = [UIColor darkGrayColor];
- } completion:^(BOOL finished) {
- [UIView animateWithDuration:TapDuration animations:^{
- self.backgroundColor = [UIColor clearColor];
- } completion:^(BOOL finished) {
- [target performSelector:action withObject:nil];
- }];
- }];
-}
-
-@end
diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj
index b17a7d7a..b17bcc94 100644
--- a/platform/ios/MuPDF.xcodeproj/project.pbxproj
+++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj
@@ -63,7 +63,6 @@
DAD72802183E53F0005C14FA /* MuAnnotSelectView.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD72801183E53F0005C14FA /* MuAnnotSelectView.m */; };
DAD72804183E6F33005C14FA /* ic_trash.png in Resources */ = {isa = PBXBuildFile; fileRef = DAD72803183E6F33005C14FA /* ic_trash.png */; };
DADF824D1905242800855662 /* ic_share.png in Resources */ = {isa = PBXBuildFile; fileRef = DADF824C1905241900855662 /* ic_share.png */; };
- DAF81D5B18800D1800B0F028 /* TapImage.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF81D5A18800D1800B0F028 /* TapImage.m */; };
DAFDB695191A32ED003956EF /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = DAFDB692191A32ED003956EF /* Icon-76.png */; };
DAFDB696191A32ED003956EF /* Icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAFDB693191A32ED003956EF /* Icon-76@2x.png */; };
DAFDB697191A32ED003956EF /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = DAFDB694191A32ED003956EF /* Icon-120.png */; };
@@ -161,8 +160,6 @@
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>"; };
DADF824C1905241900855662 /* ic_share.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_share.png; path = "../android/res/drawable-ldpi/ic_share.png"; 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>"; };
DAFDB692191A32ED003956EF /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = "<group>"; };
DAFDB693191A32ED003956EF /* Icon-76@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76@2x.png"; sourceTree = "<group>"; };
DAFDB694191A32ED003956EF /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = "<group>"; };
@@ -309,8 +306,6 @@
DAFF9978187C12430081C756 /* MuChoiceFieldController.h */,
DAFF9979187C12430081C756 /* MuChoiceFieldController.m */,
DAFF997A187C12430081C756 /* MuChoiceFieldController.xib */,
- DAF81D5918800D1800B0F028 /* TapImage.h */,
- DAF81D5A18800D1800B0F028 /* TapImage.m */,
DA012CA218803D1C00E47712 /* MuUpdater.h */,
DA0354E918FFF48400EE31BA /* MuPrintPageRenderer.h */,
DA0354EA18FFF48400EE31BA /* MuPrintPageRenderer.m */,
@@ -462,7 +457,6 @@
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 */,