From d6742f03d9b7cdd0ba590cfa77ac821a3024d0d0 Mon Sep 17 00:00:00 2001 From: micaTewe Date: Tue, 15 Sep 2015 01:13:04 +0200 Subject: [PATCH] UI adaptation on orientation Fix the sigh light size on device orientation change --- ios/AlmaZBarReaderViewController.m | 44 ++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/ios/AlmaZBarReaderViewController.m b/ios/AlmaZBarReaderViewController.m index 9144939..a799949 100644 --- a/ios/AlmaZBarReaderViewController.m +++ b/ios/AlmaZBarReaderViewController.m @@ -7,6 +7,7 @@ // #import "AlmaZBarReaderViewController.h" +#import "CsZbar.h" @interface AlmaZBarReaderViewController () @@ -14,20 +15,59 @@ @implementation AlmaZBarReaderViewController + - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. + UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; + [button setTitle:@"Turn on Flash" forState:UIControlStateNormal]; + [button sizeToFit]; + // Set a new (x,y) point for the button's center + button.center = CGPointMake(320/2, 60); + [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:button]; + } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } +//Techedge Changes NSS fase 2 +- (void)buttonPressed: (UIButton *) button { + + CsZBar *obj = [[CsZBar alloc] init]; + + [obj toggleflash]; --(BOOL)shouldAutorotate{ - return NO; } + +- (BOOL)shouldAutorotate{ + return YES; +} +- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{ + //AlmaZBarReaderViewController.scanner.scanner.cameraOverlayView = poli + //NSDictionary *params = (NSDictionary*) [command argumentAtIndex:0]; + BOOL drawSight = true;//[params objectForKey:@"drawSight"] ? [[params objectForKey:@"drawSight"] boolValue] : true; + if(drawSight){ + CGRect screenRect = [[UIScreen mainScreen] bounds]; + CGFloat screenWidth = screenRect.size.width; + CGFloat screenHeight = screenRect.size.height; + CGFloat dim = screenWidth < screenHeight ? screenWidth / 1.1 : screenHeight / 1.1; + UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( (screenWidth/2) - (dim/2), (screenHeight/2) - (dim/2), dim, dim)]; + //polygonView.center = self.scanReader.view.center; + //polygonView.layer.borderColor = [UIColor greenColor].CGColor; + //polygonView.layer.borderWidth = 3.0f; + + UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,dim / 2, dim, 1)]; + lineView.backgroundColor = [UIColor redColor]; + [polygonView addSubview:lineView]; + self.cameraOverlayView = polygonView; + + + } +} /* #pragma mark - Navigation