|
|
@@ -184,11 +184,19 @@
|
|
|
|
|
|
self.navigationItem.leftBarButtonItem = closeButton;
|
|
|
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)viewDidAppear:(BOOL)animated {
|
|
|
+ [super viewDidAppear:animated];
|
|
|
+
|
|
|
+ // 只有在此方法中取得的self.focusZone.frame才正确。
|
|
|
// return;
|
|
|
- [self.backgroundView removeFromSuperview];
|
|
|
+ // [self.backgroundView removeFromSuperview];
|
|
|
//self.back = (ScannerControllerView*)self.view;
|
|
|
self.backgroundView.highLightRect = CGRectInset(self.focusZone.frame,6,6);
|
|
|
- // self.backgroundView.autoresizingMask=0xff;
|
|
|
+ [self.backgroundView setNeedsDisplay];
|
|
|
+ // self.backgroundView.autoresizingMask=0xff;
|
|
|
self.handelOutput = false;
|
|
|
|
|
|
|
|
|
@@ -249,20 +257,20 @@
|
|
|
_previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
|
|
|
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
|
|
|
|
|
|
-// _previewLayer.orientation= AVCaptureVideoOrientationLandscapeRight;
|
|
|
+ // _previewLayer.orientation= AVCaptureVideoOrientationLandscapeRight;
|
|
|
UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
|
|
|
switch (orientation) {
|
|
|
|
|
|
-// UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
|
|
|
-// UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
|
|
|
-// UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
|
|
|
-// UIInterfaceOrientationLandscapeRight
|
|
|
+ // UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
|
|
|
+ // UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
|
|
|
+ // UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
|
|
|
+ // UIInterfaceOrientationLandscapeRight
|
|
|
|
|
|
|
|
|
-// AVCaptureVideoOrientationPortrait = 1,
|
|
|
-// AVCaptureVideoOrientationPortraitUpsideDown = 2,
|
|
|
-// AVCaptureVideoOrientationLandscapeRight = 3,
|
|
|
-// AVCaptureVideoOrientationLandscapeLeft = 4,
|
|
|
+ // AVCaptureVideoOrientationPortrait = 1,
|
|
|
+ // AVCaptureVideoOrientationPortraitUpsideDown = 2,
|
|
|
+ // AVCaptureVideoOrientationLandscapeRight = 3,
|
|
|
+ // AVCaptureVideoOrientationLandscapeLeft = 4,
|
|
|
case UIInterfaceOrientationPortrait:
|
|
|
_previewLayer.connection.videoOrientation=AVCaptureVideoOrientationPortrait;
|
|
|
break;
|
|
|
@@ -285,11 +293,12 @@
|
|
|
|
|
|
_previewLayer.bounds = rect;
|
|
|
_previewLayer.position = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
|
|
|
- [self.view.layer addSublayer:_previewLayer];
|
|
|
-
|
|
|
+ // [self.view.layer addSublayer:_previewLayer];
|
|
|
+ [self.view.layer insertSublayer:_previewLayer atIndex:0];
|
|
|
|
|
|
|
|
|
- [self.view addSubview:self.backgroundView];
|
|
|
+ // [self.view addSubview:self.backgroundView];
|
|
|
+ [self.view bringSubviewToFront:self.backgroundView];
|
|
|
|
|
|
// [self.view addSubview:self.ScannerControl.view];
|
|
|
// CGRect rt = self.ScannerControl.scannerZone.bounds;
|
|
|
@@ -309,7 +318,7 @@
|
|
|
_boundingBox = [[SCShapeView alloc] initWithFrame:self.view.bounds];
|
|
|
_boundingBox.backgroundColor = [UIColor clearColor];
|
|
|
_boundingBox.hidden = YES;
|
|
|
- [self.view addSubview:_boundingBox];
|
|
|
+ [self.view insertSubview:_boundingBox belowSubview:self.backgroundView];
|
|
|
|
|
|
// Add a label to display the resultant message
|
|
|
_decodedMessage = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.view.bounds) - 75, CGRectGetWidth(self.view.bounds), 75)];
|
|
|
@@ -318,6 +327,15 @@
|
|
|
_decodedMessage.textColor = [UIColor darkGrayColor];
|
|
|
_decodedMessage.textAlignment = NSTextAlignmentCenter;
|
|
|
[self.view addSubview:_decodedMessage];
|
|
|
+
|
|
|
+ _decodedMessage.userInteractionEnabled = YES;
|
|
|
+ UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [backBtn setTitle:@"cancel" forState:UIControlStateNormal];
|
|
|
+ backBtn.titleLabel.backgroundColor = [UIColor whiteColor];
|
|
|
+ [backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
+ backBtn.frame = CGRectMake(CGRectGetMaxX(_decodedMessage.frame) - 70, 0, 60, CGRectGetHeight(_decodedMessage.frame));
|
|
|
+ [_decodedMessage addSubview:backBtn];
|
|
|
+ [backBtn addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
self.scanButton.layer.shadowColor = [UIColor blackColor].CGColor;
|
|
|
self.scanButton.layer.shadowOffset = CGSizeMake(0, 0);
|
|
|
@@ -327,7 +345,13 @@
|
|
|
self.scanButton.layer.borderWidth = 15;
|
|
|
// Start the AVSession running
|
|
|
[session startRunning];
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+- (void)backButtonClick:(UIButton *)sender {
|
|
|
+ [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
//#pragma mark - ScannerControllerDelegate
|
|
|
//-(void)BeginScan:(bool)begin
|
|
|
//{
|