Tag: mkmapsnapshotter

从WatchKit调用MKMapSnapshotter completionHandler在父应用程序中从不调用

我有这个奇怪的问题:我打电话给父应用程序openParentApplication:reply:正常。 使用asynchronousNSURLRequests从网上获取一些数据是非常NSURLRequests但是当我想使用MKMapSnapshotter (仍然在父应用程序中)获取地图图像时,它的完成块永远不会被调用。 MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options]; [snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) { NSLog(@"completion handler is called"); //this never called }; 我试着用: snapshotter startWithQueue:调用snapshotter startWithQueue:在dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)或dispatch_get_main_queue()等,但似乎没有任何工作。 如果我直接从WKInterfaceController或从父应用程序调用相同的代码,它工作得很好。

MKMapSnapshotOptions:添加自定义引脚注解视图或UIView的快照

我正在尝试使用MKMapSnapshotter的startWithCompletionHandler方法获取地图视图的快照。 我想添加自定义引脚注释视图到快照。 在我的自定义注释视图中有一个标签。 所以当我得到快照时我不能显示这个标签。 这里是代码: let snapshotter = MKMapSnapshotter(options: options) snapshotter.startWithCompletionHandler() { snapshot, error in if error != nil { completion(image: nil, error: error) return } let image = snapshot.image let pin = MKPinAnnotationView(annotation: nil, reuseIdentifier: "") // I want to use custom annotation view instead of MKPinAnnotationView let pinImage = UIImage(named: "pinImage") UIGraphicsBeginImageContextWithOptions(image.size, true, […]

使用MKPolylineRenderer创build一个MKMapSnapshotter

我认为iOS 7的MKMapSnapshotter将是一个简单的方法来拍摄一个MKMapView的快照,好处是你可以做到这一点,而无需将地图加载到视图中。 即使看起来更多的工作来添加引脚和覆盖(因为需要核心graphics)。 WWDCvideo给出了创buildMKMapSnapshotter并添加MKAnnotationView一个很好的例子。 然而,对于没有太多核心graphics体验的人来说,如何从MKPolylineRenderer创build一个MKMapSnapshotter并不是很明显。 我试图做到这一点,但path是不准确的。 它准确地绘制了约10%的线,但是直接绘制了其余的path。 这是我的代码: MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:snapshotOptions]; [snapshotter startWithQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) completionHandler:^(MKMapSnapshot *snapshot, NSError *error) { if (error == nil) { UIImage *mapSnapshot = [snapshot image]; UIGraphicsBeginImageContextWithOptions(mapSnapshot.size, YES, mapSnapshot.scale); [mapSnapshot drawAtPoint:CGPointMake(0.0f, 0.0f)]; CGContextRef context = UIGraphicsGetCurrentContext(); //Draw the points from the MKPolylineRenderer in core graphics for mapsnapshotter… MKPolylineRenderer *overlay […]

iOS MKMapShapshotter完成块并不总是被调用

我正在尝试使用新的iOS7 MKMapSnapshotter生成静态地图图像。 每当我的应用程序需要一张地图,我打电话给以下: MKMapSnapshotter *snapshotter = [[[MKMapSnapshotter alloc] initWithOptions:theOptions] autorelease]; dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); DebugLog(@"Snapshotter allocated %@ and run on queue %@", snapshotter, aQueue); [snapshotter startWithQueue:aQueue completionHandler:^(MKMapSnapshot *snapshot, NSError *error) { DebugLog(@"Snapshotter completion block %@", snapshotter); // perform selector on main thread to set self.imageView.image = shanpshot.image; } 在大多数情况下,这是行之有效的。 然而有时候,这个设备看起来像是超载了地图请求,然后停止了渲染。 在我的日志文件中,我将看到关于“Snapshotter分配”的第一条日志语句,但从来没有看到“Snapshotter completion block”消息。 我的请求可能永远不会从调度队列中执行吗? […]