如何将SplitView控制器中的值传递给地图?

时间:2015-06-17 14:23:55

标签: swift storyboard

所以我有一个SplitView控制器,当我选择一个我知道如何使用segue进入细节视图的单元格时,单元格有城市和州(例如:Dalllas,TX等)。但是,如何发送另一个包含地图的UIViewController数据?

在我创建了segue之后,我与SplitView相关联的代码如下所示:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        let cell:UITableViewCell = sender as! UITableViewCell

        let destinationViewController:ViewController = segue.destinationViewController as! ViewController
              // “cell.textLable” is where the value is passed from the SplitView
if let text = cell.textLabel!.text {

            let incedent = LocationIncedent(sName: text)
            destinationViewController.detailString = "Lat:" + String(stringInterpolationSegment: incedent.incLat) + " Long:" + String(stringInterpolationSegment: incedent.incLong)

DestinationViewController是标签接受显示值的位置。但是,如何获取发送到地图而不是标签的值。此外,我需要将纬度和经度坐标传递给CLLocationCoordinate2D方法。

由于

1 个答案:

答案 0 :(得分:0)

您在destinationViewController为要传递的每个对象创建一个属性,并在segue方法中指定此属性。

在destinationViewController的viewDidLoad()中,您可以使用签名到这些属性的数据来​​填充MKMapView ...

相关问题