Google Maps iOS SDK - Add GMSPanoramaView in a SubView

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:54:41

问题


I'm trying to add a GMSPanoramaView to a SubView. Here is the code I'm working on :

panoView_ = [[GMSPanoramaView alloc] initWithFrame:CGRectZero];
panoView_.delegate = self;
self.view = panoView_;


[panoView_ moveNearCoordinate:CLLocationCoordinate2DMake(emplLatitude, emplLongitude)];

This code renders the panorama on fullscreen mode.

If I try this, nothing happens :

self.myView = panoView_;

Where myView outlet is set in my storyboard.

This stack is a possible duplicate of this one which never got answered.

Help appreciated :)


回答1:


Works when panoView_ is NOT inited with CGRectZero

panoView_ = [[GMSPanoramaView alloc] initWithFrame:CGRectMake(200, 200, 400, 400)];

self.myView.frame = panoView_.frame;
[self.myView addSubview:panoView_];



回答2:


I have had similar issues in the past.

Usually by setting the frame of the panoView_ to be that of the subview, it has worked for me:

self.myView.frame = panoView_.frame;

If that doesn't work, try checking to see if the panoView_ is in the subview's view hierarchy:

NSLog(@"%@", self.myView.subviews);

You can then try adding it as a subview if needed:

[self.myView addSubview:panoView_];


来源:https://stackoverflow.com/questions/28545642/google-maps-ios-sdk-add-gmspanoramaview-in-a-subview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!