如何将数据从UIViewController发送到swift ios中的UITabBarControllers第一个选项卡

时间:2015-03-26 05:42:31

标签: ios swift

首次登录屏幕。登录后我收到JSON数据我解析了data.know我需要将该数据发送到UITabBarControllers第一个viewcontroller中的viewcontroller我放置了标签。我需要用这些数据填充标签

override func prepareForSegue(segue: UIStoryboardSegue,sender:AnyObject!)
    {
        if (segue.identifier == "first")
        {

    var svc = segue.destinationViewController as Vc1;
             svc.toPass  = name
            svc.toPass1 = pid
            svc.toPass2 = sex
            svc.toPass3 = dob
            svc.toPass4 = lastvisit
            svc.toPass5 = height
            svc.toPass6 = pulse
            svc.toPass7 = respiration
            svc.toPass8 = temp
            svc.toPass9 = sysbp
            svc.toPass10 = dysbp
            svc.toPass11 = weight
            svc.toPass12 = medicine
            svc.toPass13 = date
            svc.toPass14 = dosage
            svc.toPass15 = drugclass
            svc.toPass16 = duration
            svc.toPass17 = route
            svc.toPass18 = frequency
            svc.toPass19 = drnote
            svc.toPass20 = con_dr

2 个答案:

答案 0 :(得分:3)

如果您正在使用tabBarController,则目标VC将为UITabBarController。您可以使用选项卡栏控制器的viewControllers属性访问第一个视图控制器:

let tabBarController = segue.destinationViewController as UITabBarController
let svc = tabBarController.viewControllers![0] as Vc1

答案 1 :(得分:1)

请检查此存储库中的代码。如果需要任何帮助,请告诉我。

https://github.com/jassionly4u/UITabBarController-Swift