Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for Xamarin.Android and Data Capture SDK Documentation for Xamarin.iOS

Presenting the Scandit Barcode Scanner

The scan view itself (BarcodePicker) is a UIViewController and therefore contains a normal view in iOS. You can add it to the view hierarchy like any other view and add further views on top of the overlay view or the picker itself.

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).

Displaying the scan view modally

// Set app key. This will only have to be done once
License.SetAppKey("yourAppKey");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker picker = new BarcodePicker (ScanSettings.DefaultSettings ());
// Always show a toolbar (with cancel button) so we can navigate out of the scan view.
picker.OverlayView.ShowToolBar (true);
// Set the delegate to receive callbacks.
scanDelegate = new PickerScanDelegate(this);
picker.ScanDelegate = scanDelegate;
cancelDelegate = new OverlayCancelDelegate(this);
picker.OverlayView.CancelDelegate = cancelDelegate;
// Present the barcode picker modally and start scanning. If you are presenting the controller animated
// you should consider buffering the results while the picker is still animating or only call
// StartScanning() once the animation has finished as you will not be able to close the view controller
// before its present animation has finished.
PresentViewController (picker, true, null);
picker.StartScanning ();

Displaying the scan view in a UINavigationController

// Set app key. This will only have to be done once
License.SetAppKey("yourAppKey");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker picker = new BarcodePicker (ScanSettings.DefaultSettings ());
// Set the delegate to receive scan events.
scanDelegate = new PickerScanDelegate(this);
picker.ScanDelegate = scanDelegate;
// Push the picker on the navigation stack and start scanning.
navigationController.PushViewController (picker, true);
picker.StartScanning ();

Adding the scan view to a UITabViewController

// Set app key. This will only have to be done once
License.SetAppKey("yourAppKey");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker picker = new BarcodePicker (ScanSettings.DefaultSettings ());
// Set the delegate to receive scan events.
scanDelegate = new PickerScanDelegate(this);
picker.ScanDelegate = scanDelegate;
// Create a tab item for the picker, possibly with an icon.
picker.TabBarItem = new UITabBarItem("Scan", UIImage.FromFile ("icon_barcode.png"), 3);
// Add the picker to the array of view controllers that make up the tabs.
UIViewController[] tabControllers = this.TabBarController.ViewControllers;
UIViewController[] newTabControllers = new UIViewController[tabControllers.Length + 1];
for (int i = 0; i < tabControllers.Length; i++) {
newTabControllers [i] = tabControllers [i];
}
newTabControllers[newTabControllers.Length - 1] = picker;
// And set the array as the tab bar controllers source of tabs again.
TabBarController.ViewControllers = newTabControllers;
// Switch to the last tab, where the picker is located and start scanning.
TabBarController.SelectedIndex = newTabControllers.Length - 1;
picker.StartScanning ();

Adding the scan view as a subview

// Set app key. This will only have to be done once
License.SetAppKey("yourAppKey");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker picker = new BarcodePicker (ScanSettings.DefaultSettings ());
// Set the delegate to receive scan events.
scanDelegate = new PickerScanDelegate(this);
picker.ScanDelegate = scanDelegate;
// Add the picker to the view controller's view hierarchy
AddChildViewController (picker);
View.AddSubview (picker.View);
picker.DidMoveToParentViewController (this);
picker.View.TranslatesAutoresizingMaskIntoConstraints = false;
// Add constraints to place the picker at the top of the controller with a height of 300 and
// the same width as the controller. Since this is not the aspect ratio of the video preview
// some of the video preview will be cut away at the top and bottom.
NSDictionary views = NSDictionary.FromObjectsAndKeys (
new object[] { picker.View, TopLayoutGuide },
new object[] { "pickerView", "topGuide" });
View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|[topGuide][pickerView(300)]", 0, null, views));
View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|[pickerView]|", 0, null, views));
picker.StartScanning ();