public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); //don't clean up objects, if we want the controller to be kept alive if (keepScanViewControllerAlive) { return; } //remove notification view if (notificationView != null) { notificationView.RemoveFromSuperview(); notificationView.Dispose(); notificationView = null; } //remove image if (resultImage != null) { resultImage.Dispose(); resultImage = null; } //we have to erase the scan view so that there are no dependencies for the viewcontroller left. scanView.RemoveFromSuperview(); scanView.Dispose(); scanView = null; base.Dispose(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Initializing the Bottlecap scan module. CGRect frame = UIScreen.MainScreen.ApplicationFrame; frame = new CGRect(frame.X, frame.Y + NavigationController.NavigationBar.Frame.Size.Height, frame.Width, frame.Height - NavigationController.NavigationBar.Frame.Size.Height); scanView = new AnylineDocumentModuleView(frame); // We tell the module to bootstrap itself with the license key and delegate. The delegate will later get called // by the module once we start receiving results. error = null; success = scanView.SetupWithLicenseKey(licenseKey, this.Self, out error); // SetupWithLicenseKey:delegate:error returns true if everything went fine. In the case something wrong // we have to check the error object for the error message. if (!success) { // Something went wrong. The error object contains the error description (alert = new UIAlertView("Error", error.DebugDescription, null, "OK", null)).Show(); } //stop scanning on result scanView.CancelOnResult = true; scanView.TranslatesAutoresizingMaskIntoConstraints = false; // After setup is complete we add the module to the view of this view controller View.AddSubview(scanView); // This view notifies the user of any problems that occur while scanning notificationView = new NotificationView(new CGRect(20, 115, View.Bounds.Width - 40, 30)); notificationView.fillColor = new UIColor((nfloat)(98.0 / 255.0), (nfloat)(39.0 / 255.0), (nfloat)(232.0 / 255.0), (nfloat)(0.6)).CGColor; notificationView.textLabel.Text = ""; notificationView.Alpha = 0; View.Add(notificationView); }