gpt4 book ai didi

swift - 将数据从 UIViesController 传递到 UIView, Swift ios

转载 作者:搜寻专家 更新时间:2023-11-01 06:43:22 25 4
gpt4 key购买 nike

我正在尝试将数据从我的 UIViewcoontroller 传递到我在 swift 2 上分配给 xib 文件的 UIView,我希望 var taxiName 显示在我的 UIView 内的标签上

    func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
let infoWindow = NSBundle.mainBundle().loadNibNamed("infoWindow", owner: self, options: nil).first! as! InfoWindow
if (marker.title == "Taxi0")
{
var taxiName = "Taxi0"

return infoWindow
}else if (marker.title == "Taxi1")
{

return infoWindow
}else
{
return nil
}

}

这是我的 UIView

 Class InfoWindow: UIView {

@IBOutlet weak var taxiName: UILabel!

var dataPassed: String!
@IBOutlet weak var nextView: UIButton!

最佳答案

1) 最简单的方法是:

infoWindow.taxiName.text = taxiName

2) 您可以创 build 置变量的属性或函数:

Class InfoWindow: UIView {

@IBOutlet weak var taxiName: UILabel!
@IBOutlet weak var nextView: UIButton!
var dataPassed: String! {
didSet {
taxiName.text = dataPassed
}
}

然后调用

infoWindow.passedData = taxiName

关于swift - 将数据从 UIViesController 传递到 UIView, Swift ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33221695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com