void ReleaseDesignerOutlets() { if (GetLocationButton != null) { GetLocationButton.Dispose(); GetLocationButton = null; } if (LocationTextField != null) { LocationTextField.Dispose(); LocationTextField = null; } if (QueryTextField != null) { QueryTextField.Dispose(); QueryTextField = null; } if (SearchButton != null) { SearchButton.Dispose(); SearchButton = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); SearchButton.Enabled = false; QueryTextField.Delegate = this; LocationTextField.Delegate = this; GetLocationButton.Enabled = CLLocationManager.LocationServicesEnabled; QueryTextField.AddTarget((sender, e) => SearchButton.Enabled = !string.IsNullOrEmpty(QueryTextField.Text), UIControlEvent.EditingChanged); if (CLLocationManager.LocationServicesEnabled) { locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); locationManager.LocationsUpdated += (sender, e) => { locationManager.StopUpdatingLocation(); var location = e.Locations[e.Locations.Length - 1]; LocationTextField.Text = string.Format("{0:F4}, {1:F4}", location.Coordinate.Latitude, location.Coordinate.Longitude); }; } }