How to insert long text in a UITextView

How can I insert long text in a UITexView because I have static text data. If I try to insert directly into textView.text, it shows errors. How can this be managed. Please guide. Thanks in advance.

txtView.txt = @"About us myventr.co is a web-based tool for event creation, event searching and online ticket selling whilst also serving as a social media network. myventr.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation! How is this different to other social media websites then? Myevent is about connecting people's social lives and events all at the same place. myventr.co will help find all the event details around your location and will also help avoid events clashing by simply searching the Event Calendar before creating an event."; 

Above is how I try.

+4
source share
8 answers

Do not use text on the next line, use '\ n' instead for a new line.

+5
source

You cannot insert text in different lines, if you want to have different lines, you need to set them with \ n.

For instance:

 @"This is line1\nThis is line 2" 
+4
source

If you install it programmatically, you should install it on one line:

 txtView.text = @"About us\n\nmyevent.co is a web-based tool for event creation, event searching and online ticket selling whilst also serving as a social media network. myevent.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation!\n\nHow is this different to other social media websites then? Myevent is about connecting people's social lives and events all at the same place. myevent.co will help find all the event details around your location and will also help avoid events clashing by simply searching the Event Calendar before creating an event."; 
+4
source

Try:

 txtView.txt = @"About us\n myevent.co is a web-based tool for event creation, event searching and online ticket selling whilst also serving as a social media network. myevent.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation! \nHow is this different to other social media websites then? Myevent is about connecting people's social lives and events all at the same place. myevent.co will help find all the event details around your location and will also help avoid events clashing by simply searching the Event Calendar before creating an event."; 

The error you get depends on what you specify on your line. Therefore, the compiler cannot understand the end of your statement.

+1
source

add property file 'about.plist'

 NSDictionary *dic=[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"about" ofType:@"plist"]]; NSLog(@"%@",dic); 
+1
source

Install it directly in the XIB. It can automatically process text with a new line.

+1
source

If you want to write text on several lines, you can add the \ character at the end of each line.

 txtView.txt = @"About us\ myevent.co is a web-based tool for event creation, event searching and online ticket selling whilst also serving as a social media network. myevent.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation!\ How is this different to other social media websites then? Myevent is about connecting people's social lives and events all at the same place. myevent.co will help find all the event details around your location and will also help avoid events clashing by simply searching the Event Calendar before creating an event."; 
+1
source

I am trying to find your code that you need to enter in a line where you need to use the space new (\ n) line char, where space is required as other answers. I follow your code, replacing Enter, with spaces of its work. Give it a try. It is suggested to use a new char line for a new line.

 UITextView *textView=[[UITextView alloc]initWithFrame:CGRectMake(5, 50, 320, 300)]; textView.text = @"About us myventr.co is a web-based tool for event creation, event searching and online ticket selling whilst also serving as a social media network. myventr.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation! How is this different to other social media websites then? Myevent is about connecting people's social lives and events all at the same place. myventr.co will help find all the event details around your location and will also help avoid events clashing by simply searching the Event Calendar before creating an event."; [self.view addSubview:textView]; 
+1
source

Source: https://habr.com/ru/post/1492927/


All Articles