The Scan User Interface can be presented in various ways. For alternative ways of presenting the scanner (e.g., with a UINavigationController, a UITabViewController, as a subview or in landscape mode), you can also check out the source code and the app of the ExtendedProjectSample that comes with the Scandit SDK.
All code snippets are taken from the source code of the ExtendedProjectSample that comes with the Scandit SDK (DemoViewController.m and OtherExamplesViewController.m).
- (IBAction)overlayAsView {
self.backgroundButton.hidden = NO;
[self addChildViewController:self.scanditBarcodePicker];
[self.view addSubview:self.scanditBarcodePicker.view];
[self.scanditBarcodePicker didMoveToParentViewController:self];
[self.scanditBarcodePicker.view setTranslatesAutoresizingMaskIntoConstraints:NO];
UIView *pickerView = self.scanditBarcodePicker.view;
NSDictionary *views = NSDictionaryOfVariableBindings(pickerView);
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
id topGuide = self.topLayoutGuide;
views = NSDictionaryOfVariableBindings(pickerView, topGuide);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topGuide][pickerView(300)]"
options:nil
metrics:nil
views:views]];
} else {
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(50)-[pickerView(300)]"
options:nil
metrics:nil
views:views]];
}
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[pickerView]|"
options:nil
metrics:nil
views:views]];
[self.scanditBarcodePicker startScanning];
}
- (IBAction)modallyShowScanView {
[self.scanditBarcodePicker.overlayController showToolBar:YES];
[self.scanditBarcodePicker.overlayController setCameraSwitchVisibility:SBSCameraSwitchVisibilityOnTablet];
self.scanditBarcodePicker.scanDelegate = self;
self.scanditBarcodePicker.overlayController.cancelDelegate = self;
self.modalStartAnimationDone = NO;
[self presentViewController:self.scanditBarcodePicker animated:YES completion:^{
if (self.modalBufferedResult != nil) {
[self.scanditBarcodePicker pauseScanning];
[self returnBuffer];
}
self.modalStartAnimationDone = YES;
}];
[self.scanditBarcodePicker startScanning];
}
Pushing the SBSBarcodePicker in a Navigation Controller
- (IBAction)showScanViewInNav {
if ([self isMinOSVersion:@"7.0"]) {
[settings setScanningHotSpot:CGPointMake(0.5, 0.5)];
} else {
[settings setScanningHotSpot:CGPointMake(0.5, 0.35)];
}
[self.navigationController setNavigationBarHidden:NO animated:NO];
[barcodePicker.overlayController setCameraSwitchVisibility:SBSCameraSwitchVisibilityOnTablet];
[self.navigationController pushViewController:barcodePicker animated:YES];
}
- (IBAction)showScanViewInTab {
initWithSettings:[self currentScanSettings] ];
[self setAllSettingsOnPicker:self.scanditBarcodePicker];
self.scanditBarcodePicker.scanDelegate = self;
UITabBarItem *tabItem = [[UITabBarItem alloc] initWithTitle:@"Scan"
image:[UIImage imageNamed:@"icon_barcode.png"]
tag:3];
self.scanditBarcodePicker.tabBarItem = tabItem;
NSMutableArray *tabControllers = (NSMutableArray *) [[self tabBarController] viewControllers];
[tabControllers addObject:self.scanditBarcodePicker];
[[self tabBarController] setViewControllers:tabControllers];
[[self tabBarController] setSelectedIndex:3];
[self.scanditBarcodePicker startScanning];
}