Quote:
Originally Posted by elfarez
This is going to sound like a stupid question because i have only been in the iPhone app development program for a week or so. What I would like to know is, is it possible to have links in my text view where if clicked it expands and more text is shown? This may have been worded incorrectly but i don't know how to explain it properly. Basically the reason for doing this is I have an info view that has way too much text for the user to search through to find what they need. I would like to have a title and when the user presses on it more text is shown. I understand it is not protocol for people to just hand out code or specific presiders on the forum but if someone could point me in the right direction it would be greatly appreciated.
Cheers,
Elfarez
|
There are multiple ways to approach this. You can have a table-view with a list of objects, then push a new view or add to a textView when the user selects a row.
Another way would be to connect an IBAction to a button and then when the button is clicked, expand the textView. It would be something like this:
.h
Code:
IBOutlet UITextView *textView;
//We first declare the textView, we would put this inside of the curly braces
}
-(IBAction)myAction;
//We then declare the IBAction outside of the curly braces
.m
Code:
-(void)viewDidLoad {
//When the view loads, set the textView's text to nothing
[textView setText:@""];
//You can also use dot syntax
textView.text = @"";
}
-(IBAction)myAction {
//When the action is tapped, set more text
[textView setText:@"More text here \nNext Line of text\nNext Line"];
/*We separate paragraphs with the characters \n (if you want to make a
new paragraph, you would add the characters \n)*/
}
This should expand the text when you tap a button. You will have to link the action up to a button in Interface Builder.
So, this code shows you how to set the text of a textView to nothing on startup and then to something when a button is tapped.