gpt4 book ai didi

ios - 我将如何在 iOS 的谷歌地图中添加搜索栏

转载 作者:行者123 更新时间:2023-11-29 12:57:24 25 4
gpt4 key购买 nike

这是我添加 map 和 UISearchBar 的代码,但是在 View 中看不到我的搜索栏。

-(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_;
}

最佳答案

//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);

关于ios - 我将如何在 iOS 的谷歌地图中添加搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20696007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com