(Swift) how to use Segue pass textField to TableViewCell under another ViewController?
I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let nextVC = segue.destination as! UINavigationController
let dest = nextVC.topViewController as! ViewController
let ind = sender as! customTableViewCell
let nTxt = nameTxt.text?.description
let pTxt = phoneTxt.text?.description
let eTxt = emailTxt.text?.description
let dTxt = dobTxt.text?.description
ind.lb1 = "(nTxt!)"
ind.lb2 = "(pTxt!)"
ind.lb3 = "(eTxt!)"
ind.lb4 = "(dTxt!)"
swift uitableview
add a comment |
I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let nextVC = segue.destination as! UINavigationController
let dest = nextVC.topViewController as! ViewController
let ind = sender as! customTableViewCell
let nTxt = nameTxt.text?.description
let pTxt = phoneTxt.text?.description
let eTxt = emailTxt.text?.description
let dTxt = dobTxt.text?.description
ind.lb1 = "(nTxt!)"
ind.lb2 = "(pTxt!)"
ind.lb3 = "(eTxt!)"
ind.lb4 = "(dTxt!)"
swift uitableview
add a comment |
I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let nextVC = segue.destination as! UINavigationController
let dest = nextVC.topViewController as! ViewController
let ind = sender as! customTableViewCell
let nTxt = nameTxt.text?.description
let pTxt = phoneTxt.text?.description
let eTxt = emailTxt.text?.description
let dTxt = dobTxt.text?.description
ind.lb1 = "(nTxt!)"
ind.lb2 = "(pTxt!)"
ind.lb3 = "(eTxt!)"
ind.lb4 = "(dTxt!)"
swift uitableview
I wonder how to pass the textField to my customTableViweCell. Please, someone help me! enter image description here
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let nextVC = segue.destination as! UINavigationController
let dest = nextVC.topViewController as! ViewController
let ind = sender as! customTableViewCell
let nTxt = nameTxt.text?.description
let pTxt = phoneTxt.text?.description
let eTxt = emailTxt.text?.description
let dTxt = dobTxt.text?.description
ind.lb1 = "(nTxt!)"
ind.lb2 = "(pTxt!)"
ind.lb3 = "(eTxt!)"
ind.lb4 = "(dTxt!)"
swift uitableview
swift uitableview
asked Nov 12 '18 at 21:12
Ken LeeKen Lee
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
segue.destination
will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare
so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let dest = segue.destination as? YourCustomViewController
dest?.customProp = someValue
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270195%2fswift-how-to-use-segue-pass-textfield-to-tableviewcell-under-another-viewcontr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
segue.destination
will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare
so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let dest = segue.destination as? YourCustomViewController
dest?.customProp = someValue
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
add a comment |
segue.destination
will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare
so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let dest = segue.destination as? YourCustomViewController
dest?.customProp = someValue
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
add a comment |
segue.destination
will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare
so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let dest = segue.destination as? YourCustomViewController
dest?.customProp = someValue
segue.destination
will contain the destination view controller. You should cast it to your custom view controller that will be presented. That view controller, should have properties defined that will be used to build that view. You should set those properties in prepare
so that when the destination view controller loads the view, those properties can be used to update the view components. Here's an example.
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if segue.identifier == "segue"
let dest = segue.destination as? YourCustomViewController
dest?.customProp = someValue
answered Nov 12 '18 at 21:16
ODYN-KonODYN-Kon
2,1291825
2,1291825
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
add a comment |
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
let dest = segue.destination as? YourCustomViewController dest?.lb1 = "(nTxt)" error="Value of type 'ViewController' has no member 'lb1'. " the value 'lb1' I have drop under "customerTableViewCell", and "customerTableViewCell" is under "ViewCotroller" how I link it?
– Ken Lee
Nov 12 '18 at 21:30
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 has to be a non-private member of your custom view controller class.
– ODYN-Kon
Nov 12 '18 at 21:39
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
lb1 I have drop it to customerTableViewCell, it is not a view controller class. do you have any Idea? how to pass the textField to customTableViewCell
– Ken Lee
Nov 13 '18 at 4:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270195%2fswift-how-to-use-segue-pass-textfield-to-tableviewcell-under-another-viewcontr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown