mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Fixes to get zxing compatible back to OS 3.0 as proposed by David Oster.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1349 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
8af8dea749
commit
0ab1caee3e
|
@ -230,32 +230,39 @@ CGImageRef MyCGImageCopyScreenContents(void) {
|
||||||
|
|
||||||
// [[NSUserDefaults standardUserDefaults] boolForKey:@"allowEditing"];
|
// [[NSUserDefaults standardUserDefaults] boolForKey:@"allowEditing"];
|
||||||
BOOL isCamera = (sourceType == UIImagePickerControllerSourceTypeCamera);
|
BOOL isCamera = (sourceType == UIImagePickerControllerSourceTypeCamera);
|
||||||
picker.allowsEditing = !isCamera;
|
if ([picker respondsToSelector:@selector(setAllowsEditing:)]) {
|
||||||
|
// not in 3.0
|
||||||
|
[picker setAllowsEditing:!isCamera];
|
||||||
|
}
|
||||||
if (isCamera) {
|
if (isCamera) {
|
||||||
picker.showsCameraControls = NO;
|
if ([picker respondsToSelector:@selector(setShowsCameraControls:)]) {
|
||||||
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
[picker setShowsCameraControls:NO];
|
||||||
NSString *cancelString =
|
UIButton *cancelButton =
|
||||||
|
[UIButton buttonWithType:UIButtonTypeRoundedRect];
|
||||||
|
NSString *cancelString =
|
||||||
NSLocalizedString(@"DecoderViewController cancel button title", @"");
|
NSLocalizedString(@"DecoderViewController cancel button title", @"");
|
||||||
CGFloat height = [UIFont systemFontSize];
|
CGFloat height = [UIFont systemFontSize];
|
||||||
CGSize size = [cancelString sizeWithFont:[UIFont systemFontOfSize:height]];
|
CGSize size =
|
||||||
[cancelButton setTitle:cancelString forState:UIControlStateNormal];
|
[cancelString sizeWithFont:[UIFont systemFontOfSize:height]];
|
||||||
CGRect appFrame = [[UIScreen mainScreen] bounds];
|
[cancelButton setTitle:cancelString forState:UIControlStateNormal];
|
||||||
static const int kMargin = 10;
|
CGRect appFrame = [[UIScreen mainScreen] bounds];
|
||||||
static const int kInternalXMargin = 10;
|
static const int kMargin = 10;
|
||||||
static const int kInternalYMargin = 10;
|
static const int kInternalXMargin = 10;
|
||||||
CGRect frame = CGRectMake(kMargin,
|
static const int kInternalYMargin = 10;
|
||||||
appFrame.size.height - (height + 2*kInternalYMargin + kMargin),
|
CGRect frame = CGRectMake(kMargin,
|
||||||
2*kInternalXMargin + size.width,
|
appFrame.size.height - (height + 2*kInternalYMargin + kMargin),
|
||||||
height + 2*kInternalYMargin);
|
2*kInternalXMargin + size.width,
|
||||||
[cancelButton setFrame:frame];
|
height + 2*kInternalYMargin);
|
||||||
[cancelButton addTarget:self
|
[cancelButton setFrame:frame];
|
||||||
action:@selector(cancel:)
|
[cancelButton addTarget:self
|
||||||
forControlEvents:UIControlEventTouchUpInside];
|
action:@selector(cancel:)
|
||||||
picker.cameraOverlayView = cancelButton;
|
forControlEvents:UIControlEventTouchUpInside];
|
||||||
// The camera takes quite a while to start up. Hence the 2 second delay.
|
picker.cameraOverlayView = cancelButton;
|
||||||
[self performSelector:@selector(takeScreenshot)
|
// The camera takes quite a while to start up. Hence the 2 second delay.
|
||||||
withObject:nil
|
[self performSelector:@selector(takeScreenshot)
|
||||||
afterDelay:2.0];
|
withObject:nil
|
||||||
|
afterDelay:2.0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Picker is displayed asynchronously.
|
// Picker is displayed asynchronously.
|
||||||
|
|
|
@ -48,7 +48,19 @@ static NSMutableSet *sResultParsers = nil;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NSLog(@"parsing result:\n<<<\n%@\n>>>\n", s);
|
NSLog(@"parsing result:\n<<<\n%@\n>>>\n", s);
|
||||||
#endif
|
#endif
|
||||||
for (Class c in [self resultParsers]) {
|
|
||||||
|
// Make the parser of last resort the last parser we try.
|
||||||
|
NSMutableArray *resultParsers =
|
||||||
|
[NSMutableArray arrayWithArray:[[self resultParsers] allObjects]];
|
||||||
|
NSUInteger textIndex =
|
||||||
|
[resultParsers indexOfObject:NSClassFromString(@"TextResultParser")];
|
||||||
|
if (NSNotFound != textIndex) {
|
||||||
|
// If it is present, make sure it is last.
|
||||||
|
[resultParsers exchangeObjectAtIndex:textIndex
|
||||||
|
withObjectAtIndex:[resultParsers count] - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Class c in resultParsers) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NSLog(@"trying %@", NSStringFromClass(c));
|
NSLog(@"trying %@", NSStringFromClass(c));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue