How do I send text to a UITextView?
I'm new to iphone development. I'm a VB programmer who is trying to convert a VB application to an ipad app.
I need some help with sending text to a UITextView.
I want to first have a UIPickerView and then once the user hits a UIButton, a UITextView appears and the text is then generated by my source code code, line by line. The code would constantly be concatenating strings to the text.
It would sort of go like this--
- User makes selections with UIPickerView.
- User then hits UIButton.
- UIPickerView is replaced on the screen with a UITextView.
- The code does stuff.
- The code adds the 1st line of text into the UITextView.
- The code does more stuff.
- The code then adds the 2nd line of te开发者_开发知识库xt into the UITextView, retaining the 1st line that was already there.
Steps 6 and 7 are repeated until the code is done.
Does anyone know of any examples of this that I could look at? I am mostly interested in finding something like a youtube video, a webpage that explains the code or even a good book that covers this particular topic. I am finding that the sample codes that Apple has on this site goes over my head.
In fact, I could probably benefit from a good book. But, I am looking for one that I would already know covers this particular topic, since it is so essential to the app that I am trying to build.
Appending text to a UITextView is fairly simple:
uiTextView.text = [NSString stringWithFormat:@"%@ %@", uiTextView.text, textToAppend];
As far as a good book, I've liked iPhone SDK Development and Beginning iPhone 3 Development.
I'm having trouble figuring out how, when the user hits the UIButton, how to make the GUI be replaced by a UITextView.
You could:
- Make the button hidden and the text-view visible
- Remove the button from the view and add the text view
I would have it already there, just hidden. Then unhide it and add the text, NSString has a variety of helper functions (and the text is NSString).
Safari Books Online and Lynda are my favorite resources, but there's free stuff on iTunes as well.
You need to setup IBAction with the button, and when it's hit, you'll set the UITextView's hidden to NO and do something like the other answer's appending. I like this version of:
textView.text = [textView.text stringByAppendingString:@"Other stuff I\'m appending"];
精彩评论