@@ -35,6 +35,24 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
3535
3636#pragma mark - Plugin API
3737
38+ + (UIView*) searchToolbarFrom : (UIView*) topView {
39+ UIView* result = nil ;
40+ for (UIView* testView in topView.subviews ) {
41+ if ([testView isKindOfClass: [UIToolbar class ]]){
42+ result = testView;
43+ break ;
44+ } else {
45+ if ([testView.subviews count ] > 0 ){
46+ result = [self searchToolbarFrom: testView];
47+ if (result != nil ){
48+ break ;
49+ }
50+ }
51+ }
52+ }
53+ return result;
54+ };
55+
3856- (void )scan : (CDVInvokedUrlCommand*)command ;
3957{
4058 if (self.scanInProgress ) {
@@ -49,7 +67,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
4967 self.scanReader = [AlmaZBarReaderViewController new ];
5068
5169 self.scanReader .readerDelegate = self;
52- self.scanReader .supportedOrientationsMask = ZBarOrientationMask (UIInterfaceOrientationPortrait);
70+ self.scanReader .supportedOrientationsMask = ZBarOrientationMask (UIInterfaceOrientationPortrait || UIDeviceOrientationLandscapeRight || UIDeviceOrientationLandscapeLeft );
5371
5472 // Get user parameters
5573 NSDictionary *params = (NSDictionary *) [command argumentAtIndex: 0 ];
@@ -72,16 +90,22 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
7290 }
7391
7492 // Hack to hide the bottom bar's Info button... originally based on http://stackoverflow.com/a/16353530
75- NSInteger infoButtonIndex;
76- if ([[[UIDevice currentDevice ] systemVersion ] compare: @" 10.0" options: NSNumericSearch] != NSOrderedAscending) {
77- infoButtonIndex = 1 ;
78- } else {
79- infoButtonIndex = 3 ;
93+
94+ UIView* testView = self.scanReader .view ;
95+ UIView* toolBar = [[self class ] searchToolbarFrom: testView];
96+
97+ for (UIBarButtonItem* item in ((UIToolbar*)toolBar).items ) {
98+ if (item.customView != nil ){
99+ if ([item.customView isKindOfClass: [UIButton class ]]){
100+ UIButton* but = (UIButton*)item.customView ;
101+ if (but.buttonType == UIButtonTypeInfoLight
102+ || but.buttonType == UIButtonTypeInfoDark){
103+ but.hidden = YES ;
104+ }
105+ }
106+ }
80107 }
81- UIView *infoButton = [[[[[self .scanReader.view.subviews objectAtIndex: 2 ] subviews ] objectAtIndex: 0 ] subviews ] objectAtIndex: infoButtonIndex];
82- [infoButton setHidden: YES ];
83108
84- // UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setTitle:@"Press Me" forState:UIControlStateNormal]; [button sizeToFit]; [self.view addSubview:button];
85109 CGRect screenRect = [[UIScreen mainScreen ] bounds ];
86110 CGFloat screenWidth = screenRect.size .width ;
87111 CGFloat screenHeight = screenRect.size .height ;
0 commit comments