I am trying to add a tab bar on top of my google map however, whenever I run this code xcode always crashes and tells me "fatal error: unexpectedly found nil while unwrapping an Optional value"
Here's my code:
@IBOutlet var tabControlller: UITabBar!
override func loadView() {
let camera = GMSCameraPosition.cameraWithLatitude(25.0330, longitude: 121.5654, zoom: 6.0)
let mapView = GMSMapView.mapWithFrame(CGRectMake(10, 10, 10, 10), camera: camera)
mapView.myLocationEnabled = true
mapView.settings.tiltGestures = true
mapView.settings.rotateGestures = true
view = mapView
view.insertSubview(tabControlller, aboveSubview: mapView)
// Creates a marker in the center of the map
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 25.0330, longitude: 121.5654)
marker.title = "Taipei"
marker.snippet = "Taiwan"
marker.map = mapView
let mapInsets = UIEdgeInsets(top: 100.0, left: 0.0, bottom: 0.0, right: 0.0)
mapView.padding = mapInsets
}
I am pretty sure the error comes from the view.insertSubview(tabControlller, aboveSubview: mapView) however, I am not sure how to add that tabbar on top of my google map? Do I do it programmatically or through IB?
Thanks for your help!