以下是添加地图和UISearchBar
的代码,但我的搜索栏无法在视图中看到。
-(void)setCamera {
camera = [GMSCameraPosition cameraWithLatitude:currentLatitude
longitude:currentLongitude
zoom:8];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
searchBar = [[UISearchBar alloc]initWithFrame:CGRectZero];
searchBar.frame = CGRectMake(0, 10, 100, searchBar.frame.size.height);
[mapView_ addSubview:searchBar];
self.view = mapView_;
}
答案 0 :(得分:1)
//create a search bar with 0 width and 0 height
searchBar = [[UISearchBar alloc]initWithFrame:CGRectZero];
//set the frame to 0 height because line above sets the height to zero.
searchBar.frame = CGRectMake(0, 10, 100, searchBar.frame.size.height);
//maybe something like this?
searchBar.frame = CGRectMake(0, 10, 100, 44);
答案 1 :(得分:0)
[mapView_ bringubViewToFront] 试试这个