Reputation: 686
I am facing a problem regarding UITextView content in which I am getting data from the server and if the content is large then I should display limited content and then by the use of a "Load More" titled button I can load additional content from the server.
How can I do this?
Upvotes: 0
Views: 153
Reputation: 14118
As Yusuf mentioned, it should be done at server side. Here are the base steps:
textView.text.length < fullLenght,
then display "Show More" button which will hit the service request again.
fromIndex = textView.text.length
This is the base logic. Apply this as per your service environment.
Hope this will help you.
Upvotes: 0
Reputation: 186
You can do this at server side. If data is big set a property of data true. On client side use this property for more button.
Upvotes: 1
Reputation: 4163
You fetch the total content, check its length. If It would be greater than the limited content then show the title button, and on click of button re-frame the textView and show the total content. Here I assume 200 characters can be contained in the textview having height 100
Example
UITextView *txtVw = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
[self.view addSubview:txtVw];
NSString *strContent = @"content from server";
if (strContent.length > 200) {
NSLog(@"Write your code to show the MORE title button");
}
else
{
NSLog(@"Show the text");
}
Upvotes: 0