private void SetupUI()
        {
            nfloat screenHeight = UIScreen.MainScreen.Bounds.Height;
            nfloat screenWidth  = UIScreen.MainScreen.Bounds.Width;
            nfloat heightRatio  = screenHeight / _imageHeight;
            nfloat widthRatio   = screenWidth / _imageWidth;


            UIScrollView scrollView = new UIScrollView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ScrollEnabled = true
            };

            scrollView.SizeToFit();
            scrollView.ContentMode = UIViewContentMode.ScaleAspectFill;

            View.AddSubview(scrollView);
            View.AddConstraint(NSLayoutConstraint.Create(scrollView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(scrollView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, View, NSLayoutAttribute.Right, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(scrollView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(scrollView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1, 0));

            View.BackgroundColor = Colors.BackgroundColor;

            foreach (Line line in _recognition.Lines)
            {
                foreach (Word word in line.Words)
                {
                    UIFont font = UIFont.FromName("Helvetica", ((word.BoundingBox[7] - word.BoundingBox[1]) / 3) + 1);

                    UITextField label = new UITextField()
                    {
                        BackgroundColor = UIColor.Clear,
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text = word.Text,
                        Font = font
                    };
                    scrollView.AddSubview(label);
                    nfloat leftPosition   = word.BoundingBox[0];
                    nfloat topPosition    = word.BoundingBox[1];
                    nfloat rightPosition  = word.BoundingBox[2];
                    nfloat bottomPosition = word.BoundingBox[5];

                    scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, scrollView, NSLayoutAttribute.Left, 1, leftPosition));
                    scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, scrollView, NSLayoutAttribute.Top, 1, topPosition));
                    //scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Right, NSLayoutRelation.Equal, scrollView, NSLayoutAttribute.Left, 1, rightPosition));
                    scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, scrollView, NSLayoutAttribute.Top, 1, bottomPosition));
                    scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Right, NSLayoutRelation.LessThanOrEqual, scrollView, NSLayoutAttribute.Right, 1, 0));
                    scrollView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.LessThanOrEqual, scrollView, NSLayoutAttribute.Bottom, 1, 0));
                }
            }
        }
        public static UIView ConfigureForHorizontalScrolling(this UIView view, UIScrollView parentScrollView, int left = 0, int top = 0, int right = 0, int bottom = 0)
        {
            // https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithScrollViews.html#//apple_ref/doc/uid/TP40010853-CH24-SW1

            // This define's the scroll view's content area, but doesn't cause the width to match the scroll viewer's width, width and height are still auto at this point
            view.StretchWidthAndHeight(parentScrollView, left: left, top: top, right: right, bottom: bottom);

            // Therefore we need to set the height equal to the scroll view's height as described in step 5 of the link above
            parentScrollView.AddConstraint(NSLayoutConstraint.Create(
                                               view,
                                               NSLayoutAttribute.Height,
                                               NSLayoutRelation.Equal,
                                               parentScrollView,
                                               NSLayoutAttribute.Height,
                                               1,
                                               (top + bottom) * -1));

            return(view);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Starting off by initilizing all of the components of the view.

            var stackView = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Spacing      = 25,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            var scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height));

            var NameField = new UITextField
            {
                Frame       = new CGRect(25, 20, 35, 15),
                Placeholder = "Event Name"
            };
            var AddressField = new UITextField
            {
                Frame       = new CGRect(25, 30, 35, 15),
                Placeholder = "Address"
            };
            var CityFiled = new UITextField
            {
                Frame       = new CGRect(25, 40, 35, 15),
                Placeholder = "City"
            };
            var StateField = new UITextField
            {
                Frame       = new CGRect(25, 30, 35, 15),
                Placeholder = "State"
            };
            var CountryField = new UITextField
            {
                Frame       = new CGRect(25, 30, 35, 15),
                Placeholder = "Country"
            };
            var ZipField = new UITextField
            {
                Frame       = new CGRect(25, 50, 35, 15),
                Placeholder = "ZipCode"
            };
            var DescField = new UITextField
            {
                Frame       = new CGRect(25, 50, 35, 15),
                Placeholder = "Event Description"
            };
            var SubmitButton = new UIButton(UIButtonType.System)
            {
                Frame = new CGRect(25, 90, 300, 30)
            };
            var GetImage = new UIButton(UIButtonType.System)
            {
                Frame = new CGRect(25, 60, 300, 30)
            };
            var StateLabel = new UILabel()
            {
                Text          = "Press the button to choose between Public or Private.",
                TextAlignment = UITextAlignment.Center
            };
            var isPublicButton = new UIButton(UIButtonType.System)
            {
                Frame = new CGRect(25, 90, 300, 30)
            };


            UIDatePicker DatePicker = new UIDatePicker(new CGRect(
                                                           UIScreen.MainScreen.Bounds.X - UIScreen.MainScreen.Bounds.Width,
                                                           UIScreen.MainScreen.Bounds.Height - 230,
                                                           UIScreen.MainScreen.Bounds.Width,
                                                           180));
            var calendar = new NSCalendar(NSCalendarType.Gregorian);

            calendar.TimeZone = NSTimeZone.LocalTimeZone;
            var currentDate = NSDate.Now;
            var components  = new NSDateComponents();

            components.Year = -60;
            NSDate minDate = calendar.DateByAddingComponents(components, NSDate.Now, NSCalendarOptions.None);

            DatePicker.MinimumDate = currentDate;
            DatePicker.Mode        = UIDatePickerMode.DateAndTime;

            SubmitButton.SetTitle("Submit Event", UIControlState.Normal);
            GetImage.SetTitle("Pick An Image", UIControlState.Normal);
            isPublicButton.SetTitle("Private Event", UIControlState.Normal);


            //Start putting the components together to build the view.

            stackView.AddArrangedSubview(NameField);
            stackView.AddArrangedSubview(AddressField);
            stackView.AddArrangedSubview(CityFiled);
            stackView.AddArrangedSubview(StateField);
            stackView.AddArrangedSubview(CountryField);
            stackView.AddArrangedSubview(ZipField);
            stackView.AddArrangedSubview(DescField);
            stackView.AddArrangedSubview(DatePicker);
            stackView.AddArrangedSubview(StateLabel);
            stackView.AddArrangedSubview(isPublicButton);
            stackView.AddArrangedSubview(GetImage);
            stackView.AddArrangedSubview(SubmitButton);

            scrollView.AddSubview(stackView);

            View.Add(scrollView);

            //Finializing the layout.

            scrollView.ContentSize = stackView.Frame.Size;
            scrollView.AddConstraint(stackView.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor));
            scrollView.AddConstraint(stackView.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor));
            scrollView.AddConstraint(stackView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor));
            scrollView.AddConstraint(stackView.RightAnchor.ConstraintEqualTo(scrollView.RightAnchor));

            View.AddConstraint(scrollView.TopAnchor.ConstraintEqualTo(View.TopAnchor));
            View.AddConstraint(scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor));
            View.AddConstraint(scrollView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor));
            View.AddConstraint(scrollView.RightAnchor.ConstraintEqualTo(View.RightAnchor));
            View.BackgroundColor = UIColor.White;
            var g = new UITapGestureRecognizer(() => View.EndEditing(true));

            View.AddGestureRecognizer(g);


            //Button function #1: submitting the event and presenting the submission to the user.
            SubmitButton.TouchUpInside += async(object sender, EventArgs e) =>
            {
                //Populate the Event model.
                userEvent.Address   = AddressField.Text;
                userEvent.EventName = NameField.Text;
                userEvent.City      = CityFiled.Text;
                userEvent.State     = StateField.Text;
                userEvent.Country   = CountryField.Text;
                userEvent.ZipCode   = int.Parse(ZipField.Text);
                DateTime.SpecifyKind((DateTime)DatePicker.Date, DateTimeKind.Utc).ToLocalTime();
                userEvent.DateOfEvent = (DateTime)DatePicker.Date;
                userEvent.isPublic    = isPublic;
                var    geoCoder     = new CLGeocoder();
                var    location     = new CLLocation();
                string worldAddress = userEvent.Address + ", "
                                      + userEvent.City + ", "
                                      + userEvent.State + ", "
                                      + userEvent.Country + ", "
                                      + userEvent.ZipCode.ToString();
                var placemarks = geoCoder.GeocodeAddressAsync(worldAddress);
                await placemarks.ContinueWith((addresses) =>
                {
                    foreach (var address in addresses.Result)
                    {
                        location = address.Location;
                    }
                });

                userEvent.Lat         = location.Coordinate.Latitude;
                userEvent.Long        = location.Coordinate.Longitude;
                userEvent.Description = DescField.Text;

                EventService ES = new EventService(_client);
                if (userImage != null)
                {
                    Event EventLocation = await ES.CreateNewEvent(userEvent, userImage);

                    var ShowEvent = new SubmittedEvent(EventLocation, _client, _locationmanager);
                    this.NavigationController.PopViewController(true);
                    this.NavigationController.PushViewController(ShowEvent, true);
                }
                else
                {
                    Event EventLocation = await ES.CreateNewEvent(userEvent);

                    var ShowEvent = new SubmittedEvent(EventLocation, _client, _locationmanager);
                    this.NavigationController.PopViewController(true);
                    this.NavigationController.PushViewController(ShowEvent, true);
                }
            };

            //Button function #2: opening Image Picker
            GetImage.TouchUpInside += (object sender, EventArgs e) =>
            {
                ShowSelectPicPopup();
            };

            //Button function #3: Public/Private toggle function
            isPublicButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (isPublic == false)
                {
                    isPublic = true;
                    isPublicButton.SetTitle("Public Event", UIControlState.Normal);
                }
                else
                {
                    isPublic = false;
                    isPublicButton.SetTitle("Private Event", UIControlState.Normal);
                }
            };
        }