自定义InfoWindow,用于标记Google Maps SDK,Swift 2.0 [英] Custom InfoWindow for marker Google Maps SDK, Swift 2.0

查看:103
本文介绍了自定义InfoWindow,用于标记Google Maps SDK,Swift 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施此操作( https://www.youtube.com/watch? v = ILiBXYscsyY )自定义InfoWindow教程,该教程是在Swift 2.0中为Objective-C完成的.我只是通过混合匹配Objective-C和Swift代码来尝试执行此操作,但是在翻译方面我一直没有成功

I'm trying to implement this (https://www.youtube.com/watch?v=ILiBXYscsyY) Custom InfoWindow tutorial that was done for Objective-C in Swift 2.0. I have tried doing this by just mix-matching Objective-C and Swift code, but I have been unsuccessful in translating

- (UIView *) mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
    CustomInfoWindow *infoWindow = [[[NSBundle MainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0];
    infoWindow.name.text = @"Syndey Opera House";
    infoWindow.address.text = @"Bennelong Point, Sydney";
    infoWindow.photo.image = [UIImage imageNamed:@"SydneyOperaHouseAtNight"];

    return infoWindow;
}

进入Swift.可以在视频的3:07处找到教程的这一部分.

into Swift. This part of the tutorial can be found at 3:07 of the video.

在将本教程翻译成Swift 2.0时,我希望获得一些帮助,或者如果有人知道关于Swift 2.0的本教程的好教程,将不胜感激.

推荐答案

以下是上面的快速代码:

Here is the swift code for the above:

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
         let infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindow", owner: self, options: nil).first as! CustomInfoWindow
        infoWindow.name.text = "Sydney Opera House"
        infoWindow.address.text = "Bennelong Point Sydney"
        infoWindow.photo.image = UIImage(named: "SydneyOperaHouseAtNight")
        return infoWindow
    }

这篇关于自定义InfoWindow,用于标记Google Maps SDK,Swift 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆