我有一个使用RubyMotion构建的iOS应用程序(使用Promotion框架)。我正在尝试加载一个只是谷歌地图视图(GMSMapView)的视图 - 他们的example even,它在设备或模拟器上第一次安装应用程序时加载正常,但会立即崩溃一次之后;或者即使该屏幕关闭然后重新打开而不关闭应用程序。
代码只是Google的“Hello World”示例,而我正在敲打着我的脑袋。我的代码如下所示,除了尝试将其作为促销屏幕之外,我还尝试通过继承新的UIViewController并获得相同的错误。
我的代码:
class MapScreen < PM::Screen
def on_load
camera = GMSCameraPosition.cameraWithLatitude(-33.868, longitude: 151.2086, zoom: 6)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)
marker = GMSMarker.new
marker.position = camera.target
marker.snippet = "Hello World"
marker.appearAnimation = 1
marker.map = mapView
mapView.delegate = self
# self.view = mapView
self.view.addSubview(mapView)
end
end
这是崩溃日志的相关部分:
Crashed Thread: 2 Dispatch queue: com.google.Maps.TileDataCacheQueue
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000656d69546e77
Thread 0:: Dispatch queue: NSPersistentStoreCoordinator 0x11c34be80
0 libobjc.A.dylib 0x000000010177302c objc_msgSend + 44
1 CoreData 0x00000001020e09d3 -[NSSQLModel _generateModel:error:] + 1363
2 CoreData 0x0000000101fc5481 -[NSSQLModel initWithManagedObjectModel:configurationName:retainHashHack:brokenHashVersion:] + 305
3 CoreData 0x0000000101fc4823 -[NSSQLCore initWithPersistentStoreCoordinator:configurationName:URL:options:] + 819
4 CoreData 0x00000001020ac77d __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 1069
5 CoreData 0x00000001020b9c30 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 192
6 libdispatch.dylib 0x0000000106e50964 _dispatch_client_callout + 8
7 libdispatch.dylib 0x0000000106e39fca _dispatch_barrier_sync_f_invoke + 76
8 CoreData 0x00000001020ab245 _perform + 197
9 CoreData 0x0000000101fc42e1 -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 337
10 com.mwc.mwcpa2015 0x000000010002a341 -[GMSCacheStorage initWithName:modelBundle:modelName:directory:reset:] + 669
11 com.mwc.mwcpa2015 0x00000001001c3574 -[GMSServices initWithDisplayLink:resourceCache:] + 3617
12 com.mwc.mwcpa2015 0x00000001001c1d1f __43-[GMSAsyncInitServices sharedInitWithSync:]_block_invoke_2 + 105
13 com.mwc.mwcpa2015 0x00000001001c1c89 __43-[GMSAsyncInitServices sharedInitWithSync:]_block_invoke + 354
14 com.mwc.mwcpa2015 0x00000001001c1ae3 -[GMSAsyncInitServices sharedInitWithSync:] + 326
15 com.mwc.mwcpa2015 0x00000001001c191b -[GMSAsyncInitServices initSync] + 69
16 com.mwc.mwcpa2015 0x00000001001c25e0 +[GMSServices sharedServicesSync] + 183
17 com.mwc.mwcpa2015 0x00000001001b7814 -[GMSMapView sharedInitWithServices:camera:] + 162
18 com.mwc.mwcpa2015 0x00000001001b7112 -[GMSMapView initWithFrame:camera:] + 121
19 com.mwc.mwcpa2015 0x00000001001b6fb1 +[GMSMapView mapWithFrame:camera:] + 104
Thread 2 Crashed:: Dispatch queue: com.google.Maps.TileDataCacheQueue
0 libobjc.A.dylib 0x000000010175bcc1 class_getSuperclass + 11
1 com.mwc.mwcpa2015 0x00000001009e0af6 rb_objc_convert_immediate + 118
2 com.mwc.mwcpa2015 0x00000001002b14a9 vm_ocval_to_rval + 153
3 com.mwc.mwcpa2015 0x00000001002fee18 __unnamed_71 + 24
4 com.mwc.mwcpa2015 0x000000010003010e __47-[GMSTileDataCache startWithCompletionHandler:]_block_invoke57 + 639
5 com.mwc.mwcpa2015 0x000000010003496b -[GMSTileDataCache fetchTilesImmediateWithPredicate:sortDescriptor:completionHandler:] + 351
6 com.mwc.mwcpa2015 0x000000010002fd78 __47-[GMSTileDataCache startWithCompletionHandler:]_block_invoke + 412
7 libdispatch.dylib 0x0000000106e35f16 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x0000000106e50964 _dispatch_client_callout + 8
9 libdispatch.dylib 0x0000000106e3acb4 _dispatch_queue_drain + 435
10 libdispatch.dylib 0x0000000106e3a9a3 _dispatch_queue_invoke + 217
11 libdispatch.dylib 0x0000000106e3cc85 _dispatch_root_queue_drain + 534
12 libdispatch.dylib 0x0000000106e3dd59 _dispatch_worker_thread3 + 98
13 libsystem_pthread.dylib 0x00000001071b9637 _pthread_wqthread + 729
14 libsystem_pthread.dylib 0x00000001071b740d start_wqthread + 13
这让我发疯,任何帮助都会非常感激!
答案 0 :(得分:0)
您的标记正在丢失其参考并收集垃圾。尝试一下伊娃:
class MapScreen < PM::Screen
def on_load
camera = GMSCameraPosition.cameraWithLatitude(-33.868, longitude: 151.2086, zoom: 6)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)
@marker = GMSMarker.new
@marker.position = camera.target
@marker.snippet = "Hello World"
@marker.appearAnimation = 1
@marker.map = mapView
mapView.delegate = self
# self.view = mapView
self.view.addSubview(mapView)
end
end