I am having a trouble on exporting text data. I have a view contains over 3 different uitextview that allow user to type in data. Then i want to export these texts from the 3 different uitextview (e.g. textview1, textview2 and textview3) into a new uiviewcontroller that contains only one uitextview. I also want the textview 1-3 are placed in order. So that the new uitextview will have three different sections in the order of 1-3. I am using PrepareFroSegue method. How should i code this? Many thanks!
-
what do you mean by `How should i code this` ? , what have you tried? post your code for `PrepareFroSegue method`. – SpaceDust__ May 01 '13 at 14:06
2 Answers
What you want to do is concatenate (combine) the strings into one NSString that will be sent into the next view. You can do this in your PrepareForSegue. Put this in your prepareforsegue but edit the code so it works with your code.
NSString *concatenatedString = [NSString stringWithFormat:@"%@ %@ %@", textview1.text, textview2.text, textview3.text];
YourViewController *dV = [segue destinationViewController];
dV.stringToStoreValue = concatenatedString;
- The first line I concatenate the string
- The second line I get the destination view controller from the segue
The third line I set the text to a NSString @property in the destination view controller. You must then in the view did load of the destination view controller set
yourcombinedtextfield.text = stringToStoreValue;
I do not directly set the value of the text field in the prepareForSegue because if the view has not loaded yet then the I would be setting nothing and not see the string on the next page in the textfield!

- 145
- 6
You're trying to communicate between ViewControllers this answer looks like a good starting point for understanding how this is done..
UPDATE :
newController.textView.text = [NSString stringWithFormat:@"%@ %@ %@", textView1.text, textView2.text, textView3.text];

- 1
- 1

- 164
- 1
- 8
-
Thanks. I know how to passing the text from one view to another. My biggest problem is how to place two or more texts from many uitextview into one. At the same time, in the order i want. Thanks – Clarence May 01 '13 at 14:08
-
You could do something like: newController.textView.text = [NSString stringWithFormat:@"%@ %@ %@", textView1.text, textView2.text, textView3.text]; – Michael Sena May 01 '13 at 14:14