在UIViewController中点击搜索栏文本字段时,应用程序崩溃
我的ViewController看起来像这样 -
class DetailViewController: UIViewController, GMSMapViewDelegate, UISearchBarDelegate {
let testBaseUrl = "https://maps.googleapis.com/maps/api/geocode/json?"
var searchBar = UISearchBar()
var searchImageView : UIImageView!
var mapView: GMSMapView!
var markers = [GMSMarker]()
var cameraPosition: GMSCameraPosition!
var searchAddress: String!
var mapButton = UIBarButtonItem()
var listButton = UIBarButtonItem()
var filterButton = UIBarButtonItem()
var arrayOfButtons = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
cameraPosition = GMSCameraPosition.cameraWithLatitude(-37.809487,
longitude:144.965699, zoom:17.5, bearing:30, viewingAngle:40)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera:cameraPosition)
mapView.delegate = self
self.view = mapView
}
override func viewWillAppear(animated: Bool) {
setUISearchView()
} …Run Code Online (Sandbox Code Playgroud)