下面是我在新故事板中显示视图控制器的方法:
// Show create account page with custom Transitionvar storyboard : UIStoryboard = UIStoryboard(name: Storyboardname,bundle: nil)var vc : UIVIEwController = storyboard.instantiateVIEwControllerWithIDentifIEr(NewVIEwController) as UIVIEwController
我尝试在这里发送信息:
// Pass the delegate to the first vIEw controllerlet newVIEwController:NewVIEwController = NewVIEwController()newVIEwController.createAccountDelegate = selfnewVIEwController.teststring = "hello"
然后呈现视图控制器.
vc.TransitioningDelegate = selfvc.modalTransitionStyle = UIModalTransitionStyle.CoverVerticalself.presentVIEwController(vc,animated: true,completion: nil)
这是我的NewVIEwController,我尝试接收值.但最终仍然是零.
import UIKitclass NewVIEwController: UIVIEwController { var createAccountDelegate:AccountCreationDelegate! var teststring:Nsstring! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() }
我错误地发送了这些值吗?
解决方法 您正在使用此行创建NewVIEwController的新实例let newVIEwController:NewVIEwController = NewVIEwController()
而是将变量和委托分配给已从StoryBoard实例化的vc
var storyboard : UIStoryboard = UIStoryboard(name: Storyboardname,bundle: nil)// It is instance of `NewVIEwController` from storyboard var vc : NewVIEwController = storyboard.instantiateVIEwControllerWithIDentifIEr(NewVIEwController) as NewVIEwController// Pass delegate and variable to vc which is NewVIEwControllervc.createAccountDelegate = selfvc.teststring = "hello"vc.TransitioningDelegate = selfvc.modalTransitionStyle = UIModalTransitionStyle.CoverVerticalself.presentVIEwController(vc,completion: nil)总结
以上是内存溢出为你收集整理的ios – 在新的Storyboard中将值传递给UIViewController – Swift全部内容,希望文章能够帮你解决ios – 在新的Storyboard中将值传递给UIViewController – Swift所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)