diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..6b30c74
--- /dev/null
+++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,10 @@
+
+
+
+
+ BuildSystemType
+ Original
+ PreviewsEnabled
+
+
+
diff --git a/ios/Classes/BarcodeScannerViewController.m b/ios/Classes/BarcodeScannerViewController.m
index da44ca0..0366f0d 100644
--- a/ios/Classes/BarcodeScannerViewController.m
+++ b/ios/Classes/BarcodeScannerViewController.m
@@ -10,6 +10,34 @@
@implementation BarcodeScannerViewController {
}
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator
+{
+ CGRect bounds = [UIScreen mainScreen].bounds;
+ CGRect reversedBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);
+ self.previewView.bounds = reversedBounds;
+ self.previewView.frame = reversedBounds;
+ [self.scanRect removeFromSuperview];
+ [self setupScanRect:reversedBounds];
+ [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+}
+
+- (void)setupScanRect:(CGRect)bounds {
+ self.scanRect = [[ScannerOverlay alloc] initWithFrame:bounds];
+ self.scanRect.translatesAutoresizingMaskIntoConstraints = NO;
+ self.scanRect.backgroundColor = UIColor.clearColor;
+ [self.view addSubview:_scanRect];
+ [self.view addConstraints:[NSLayoutConstraint
+ constraintsWithVisualFormat:@"V:[scanRect]"
+ options:NSLayoutFormatAlignAllBottom
+ metrics:nil
+ views:@{@"scanRect": _scanRect}]];
+ [self.view addConstraints:[NSLayoutConstraint
+ constraintsWithVisualFormat:@"H:[scanRect]"
+ options:NSLayoutFormatAlignAllBottom
+ metrics:nil
+ views:@{@"scanRect": _scanRect}]];
+ [_scanRect startAnimating];
+}
- (void)viewDidLoad {
[super viewDidLoad];
@@ -26,21 +54,7 @@
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"previewView": _previewView}]];
- self.scanRect = [[ScannerOverlay alloc] initWithFrame:self.view.bounds];
- self.scanRect.translatesAutoresizingMaskIntoConstraints = NO;
- self.scanRect.backgroundColor = UIColor.clearColor;
- [self.view addSubview:_scanRect];
- [self.view addConstraints:[NSLayoutConstraint
- constraintsWithVisualFormat:@"V:[scanRect]"
- options:NSLayoutFormatAlignAllBottom
- metrics:nil
- views:@{@"scanRect": _scanRect}]];
- [self.view addConstraints:[NSLayoutConstraint
- constraintsWithVisualFormat:@"H:[scanRect]"
- options:NSLayoutFormatAlignAllBottom
- metrics:nil
- views:@{@"scanRect": _scanRect}]];
- [_scanRect startAnimating];
+ [self setupScanRect:self.view.bounds];
self.scanner = [[MTBBarcodeScanner alloc] initWithPreviewView:_previewView];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
[self updateFlashButton];