我尝试在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
更多推荐
发布评论