如何确保将selectedFocus
发送到prepareForSeque中的下一个视图控制器? (或根据prepareForSeque中分段控制按钮的哪个部分分配变量?)"Use of unresolved identifier 'segmentedControlVariable"
是我的错误。
class SecondSignUpViewController: UIViewController {
// DECLARATIONS...
// user's focus to be sent to next view contr.
var selectedFocus = String()
// 1. LOAD IN SENT VARS (so that it exists in this view) (at top it seems oposed to in viewdidload?...)
var passedPassword_toView2:String!
var passedUsername_toView2:String!
var passedEmail_toView2:String!
@IBAction func continueButtonPressed2(sender: AnyObject) {
performSegueWithIdentifier("SegueAfterJoin2", sender: self)
}
@IBAction func indexChanged(sender: AnyObject) {
switch segmentedControl.selectedSegmentIndex {
case 0:
print("case0")
textLabel.text = "You are a music artist who needs services.";
imageShown.image = image0
selectedFocus = "artist"
case 1:
print("case1")
textLabel.text = "You want to share your talent with music artists.";
imageShown.image = image1
selectedFocus = "provider"
default:
break;
}
}
// VAR SHIFT
// GET FROM PREV. VIEW
override func viewDidLoad() {
super.viewDidLoad()
print("view 2 loaded")
// 2. (for ease,) TRANSFER TO VAR NAMES
var myLocalPassword = passedPassword_toView2
var myLocalUsername = passedUsername_toView2
var myLocalEmail = passedEmail_toView2
}
// 3. SEND VARS TO NEW VIEW
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "SegueAfterJoin2") {
var nextViewCont = segue!.destinationViewController as! ThirdSignUpViewController;
// PASS VARS FROM THIS VIEW TO NEXT
nextViewCont.passedPassword_toView3 = passedPassword_toView2
nextViewCont.passedEmail_toView3 = passedUsername_toView2
nextViewCont.passedUsername_toView3 = passedEmail_toView2
//how can I toss this in too?
nextViewCont.passedFocus_toView3 = selectedfocus
}
}
答案 0 :(得分:1)
是否创建了passedFocus_toView3
变量
喜欢
在您的第一个视图控制器上,名为
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "YourSegueName") {
//get a reference to the destination view controller
let destinationVC:ViewControllerClass = segue.destinationViewController as! ViewControllerClass
//set properties on the destination view controller
destinationVC.passedFocus_toView3 = selectedfocus
//etc...
}
}