Swift - 页面传值

来源:互联网 发布:淘宝密码修改 编辑:程序博客网 时间:2024/06/04 21:45

一、通过segue传值

    overridefunc prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {        print("this is segue")        var destinationViewController = segue.destinationViewController        destinationViewController.setValue("lalalala", forKey: "str")//只能用KVC,还可以传递IndexPath     }

二、实例化ViewController的时候传值

              let vc2 = self.storyboard?.instantiateViewControllerWithIdentifier("MainPageTabBarController")                    as!MainPageTabBarController              self.navigationController?.pushViewController(vc2, animated: true)                self.DownloadWeiBOAvatar(AvatarUrlfR)                self.UPloadPath = UPLOADPath                self.UPloadToken = UPLOADToken                self.Fid = fid  

三、实例化Cell的时候传值

            let cell = tableView.dequeueReusableCellWithIdentifier("MissionTitleTableViewCell") as! MissionTitleTableViewCell            cell.BeautyMZTitleLabel.text = "美丽杂志"            cell.MoreInfoBtn.hidden = true            cell.MoreLogeImgV.hidden = true            return cell
2 0
原创粉丝点击