如何将iOS版谷歌SDK实现到iPhone 4(How to implement google map SDK for iOS to iPhone 4)

编程入门 行业动态 更新时间:2024-10-14 14:14:27
如何将iOS版谷歌SDK实现到iPhone 4(How to implement google map SDK for iOS to iPhone 4)

我尝试在iPhone 4和iPhone 5上使用Google Maps SDK for iOS在模拟器上显示自定义地图视图。

我为Google map创建了一个UIViewController类。这是代码

//GoogleMapViewController.h

#import <GoogleMaps/GoogleMaps.h>// for google map @interface GoogleMapViewController : UIViewController{ GMSMapView *mapView_; }

//GoogleMapViewController.m

- (void)viewDidLoad { [super viewDidLoad]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:13.909366 longitude:100.517446 zoom:5]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; self.view = mapView_; }

我将GoogleMapViewController加载到子视图中

//RealTimeMonitoring.h

@interface RealTimeMonitoring : UIViewController <UITableViewDataSource, UITableViewDelegate> @property (strong, nonatomic) IBOutlet UIView *googleMapView; @end

//RealTimeMonitoring.m

#import "GoogleMapViewController.h" - (void)viewDidLoad { [super viewDidLoad]; GoogleMapViewController *googleViwController = [[GoogleMapViewController alloc] initWithNibName:@"GoogleMapViewController" bundle:nil]; googleViwController.view.frame = self.googleMapView.bounds; [self.googleMapView addSubview:googleViwController.view]; }

当我在iPhone 5模拟器上运行它时,它正确显示并且地图视图上的摄像头中心看起来没问题

但是当我在iPhone模拟器上运行它时,它似乎会削减较低的部分,但相机仍然像它一样居中

当我使用Coco2d编码游戏时,我记得我必须根据设备设置大小或初始视图。 但是,当我使用界面构建器时,我不知道如何。

问题:如何让它在iPhone 4上显示为iPhone 5

PS。 我仍然使用Macbook pro 13英寸2011年晚些时候,OS X 10.7.5上的Xcode 4.5.1并计划很快更新到小牛队

谢谢。

I try to show custom map view using Google Maps SDK for iOS on iPhone 4 and iPhone 5 on simulator.

I create a UIViewController class for Google map Here is code

//GoogleMapViewController.h

#import <GoogleMaps/GoogleMaps.h>// for google map @interface GoogleMapViewController : UIViewController{ GMSMapView *mapView_; }

//GoogleMapViewController.m

- (void)viewDidLoad { [super viewDidLoad]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:13.909366 longitude:100.517446 zoom:5]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; self.view = mapView_; }

and I load GoogleMapViewController to subview like this

//RealTimeMonitoring.h

@interface RealTimeMonitoring : UIViewController <UITableViewDataSource, UITableViewDelegate> @property (strong, nonatomic) IBOutlet UIView *googleMapView; @end

//RealTimeMonitoring.m

#import "GoogleMapViewController.h" - (void)viewDidLoad { [super viewDidLoad]; GoogleMapViewController *googleViwController = [[GoogleMapViewController alloc] initWithNibName:@"GoogleMapViewController" bundle:nil]; googleViwController.view.frame = self.googleMapView.bounds; [self.googleMapView addSubview:googleViwController.view]; }

When I run it on iPhone 5 simulator it show correctly and the center of camera on map view look OK

But when I run it on iPhone simulator it seem to cut lower part a bit but the camera still center like it

When I coding game using Coco2d I recall that I must set the size or init view according to the device. But when I use interface builder I don't know how.

Question: How can I make it show like iPhone 5 on iPhone 4

Ps. I still using macbook pro 13-inch Late 2011, Xcode 4.5.1 on OS X 10.7.5 and planing to update to mavericks soon

Thank.

最满意答案

你是否使用自动布局的故事板?

如果是这样,请转到故事板。选择地图视图然后转到

编辑器> pin>顶部空间到superview编辑器> pin>底部速度到superview编辑器> pin>前导空间到superview编辑器> pin>尾随空间到superview

Do you use storyboard with autolayout?

if so, go to the storyboard..select the view of the map and then go to

Editor > pin > top space to superview Editor > pin > bottoms pace to superview Editor > pin > leading space to superview Editor > pin > trailing space to superview

更多推荐

本文发布于:2023-08-07 01:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459414.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   版谷歌   iOS   SDK   map

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!