Google 地图动画相机位置 iOS 7 问题

2023-12-01

我正在尝试将 Google Maps API 安装到 iOS7 的应用程序中。在遵循 Google 的指南和视频后,我最终遇到了以下错误:[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10b98e6c0

我正在使用 Storyboard,并尝试使该地图显示在同一 viewController 中的 TableView 上方。

在此应用程序中,我使用 Parse,它将数据提取到我的 TableView,并且工作正常。

我尝试使用在 StackOverflow 上找到的一些建议,但问题仍然存在:

无法将谷歌地图 GMSMapView 放在主主视图的子视图中?

如何设置地图视图的框架 - 在 iOS 6 的谷歌 GMS 地图中

显然这个问题与此方法有关:

mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

当我删除它时,错误就消失了。

我的 TestViewController 编码如下(没有表格或任何东西,但仍然无法工作):

//  TesteViewController.m

//



#import "TesteViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#import "AppDelegate.h"

@interface TesteViewController ()

@end

@implementation TesteViewController{
    GMSMapView *mapView_;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    // Create a GMSCameraPosition that tells the map to display the
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;
    self.view = mapView_;

    // Creates a marker in the center of the map.
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
    marker.title = @"Sydney";
    marker.snippet = @"Australia";
    marker.map = mapView_;




}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end

我还按照建议导入了所有框架,并放置了-ObjC进入我的otherLinkerFlags, 没有成功。

除此之外,我测试了在新的空白项目中使用的过程,它工作得很好,但是,当我尝试添加空白时viewController只是作为对原始项目的测试,它不起作用。

我做的另一个测试是向这个空白添加一个视图viewController并尝试我上面发布的 StackOverflow 参考文献中所述的内容。

有人对正在发生的事情有什么建议吗?

也许与 Parse 的框架或其他库有冲突?

而不是使用-ObjC我也尝试过-force_load $(PROJECT_DIR)/GoogleMaps.framework/GoogleMaps并且错误消失了,它要求我允许我的当前位置,但屏幕未加载。


您要做的就是在“项目”构建设置中添加 -objC 标志,而不是“目标”的构建设置。

正如 Google 文档的以下部分中提到的

**" Choose your project, rather than a specific target, and open the
    Build Settings tab. In the Other Linker Flags section, add -ObjC. If
    these settings are not visible, change the filter in the Build
    Settings bar from Basic to All. "**

通过这种方式,我能够解决谷歌地图动画相机位置问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Google 地图动画相机位置 iOS 7 问题 的相关文章

随机推荐