我正在尝试在我的iOS应用程序中设置Google地图,但是在InvalidArgumentException上遇到了崩溃。
有些人已经问过同样的问题;然而,他们要么没有得到有用的答复,要么给出的答复没有解决问题。
代码直接从Google的Getting Started页面复制:
#import "XXMapViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@interface XXMapViewController ()
@end
@implementation XXMapViewController{
GMSMapView *mapView_;
}
- (void)viewDidLoad
{
[super viewDidLoad];
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_;
// Do any additional setup after loading the view, typically from a nib.
}
@end
这是它崩溃的线,所以我确定设置视图不是问题:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
这是堆栈跟踪(为了匿名,应用程序名称为X'd):
2014-04-17 14:24:19.909 XX App[28758:60b] -[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10ae45a80
2014-04-17 14:24:19.931 XX App[28758:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10ae45a80'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103b2b495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010388a99e objc_exception_throw + 43
2 CoreFoundation 0x0000000103bbc65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000103b1cd8d ___forwarding___ + 973
4 CoreFoundation 0x0000000103b1c938 _CF_forwarding_prep_0 + 120
5 XX App 0x0000000100189323 -[GMSMapView setCamera:] + 161
6 XX App 0x0000000100187cc2 -[GMSMapView sharedInitWithServices:camera:] + 1440
7 XX App 0x00000001001870be -[GMSMapView initWithFrame:camera:] + 121
8 XX App 0x0000000100186f5f +[GMSMapView mapWithFrame:camera:] + 102
9 XX App 0x000000010000eeae -[XXMapViewController viewDidLoad] + 238
10 UIKit 0x000000010252d59e -[UIViewController loadViewIfRequired] + 562
11 UIKit 0x000000010252d777 -[UIViewController view] + 29
12 UIKit 0x00000001025442c5 -[UINavigationController _startCustomTransition:] + 628
13 UIKit 0x000000010254f6f5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 401
14 UIKit 0x0000000102550238 -[UINavigationController __viewWillLayoutSubviews] + 43
15 UIKit 0x000000010266a895 -[UILayoutContainerView layoutSubviews] + 202
16 UIKit 0x0000000102497993 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
17 QuartzCore 0x0000000100e77802 -[CALayer layoutSublayers] + 151
18 QuartzCore 0x0000000100e6c369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
19 QuartzCore 0x0000000100e6c1ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
20 QuartzCore 0x0000000100ddffb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
21 QuartzCore 0x0000000100de1030 _ZN2CA11Transaction6commitEv + 394
22 QuartzCore 0x0000000100de169d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
23 CoreFoundation 0x0000000103af6dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24 CoreFoundation 0x0000000103af6d37 __CFRunLoopDoObservers + 391
25 CoreFoundation 0x0000000103ad6522 __CFRunLoopRun + 946
26 CoreFoundation 0x0000000103ad5d83 CFRunLoopRunSpecific + 467
27 GraphicsServices 0x000000010491cf04 GSEventRunModal + 161
28 UIKit 0x0000000102437e33 UIApplicationMain + 1010
29 XX App 0x000000010000ed93 main + 115
30 libdyld.dylib 0x000000010434c5fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我已将-ObjC标志添加到我的项目中,并尝试将其添加到目标中,正如其他人所建议的那样;但是,将其添加到目标会导致构建失败。我也创建了一个新的单一视图项目,按照完全相同的说明工作正常。我有正确的API密钥,并且在我的API控制台中启用了Google Maps for iOS。这一直非常令人沮丧,并且是完成我的项目的巨大障碍。如果有人能指出我正确的方向,我将非常感激。
答案 0 :(得分:0)
这是与Parse依赖项的冲突。解决方案是消除FB SDK依赖关系或者只是下载SDK。我选择了后者,因为我不可避免地会在我的应用程序中使用它。