txtView.text = @"About us myventr.co is a web-based tool ... very long string ...";
// 編譯報錯或運行時截斷
\n 或隱式拼接。txtView.txt,正確是 txtView.text。// 方式一:隱式拼接(推薦,編譯器自動合併)
txtView.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.";
// 方式二:顯式 \n 換行(若需保留換行顯示)
txtView.text = @"Line 1\nLine 2\nLine 3";
// 方式三:從文件/網絡加載(超長文本最佳實踐)
NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"txt"];
txtView.text = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
txtView.editable = NO; 僅展示。txtView.dataDetectorTypes = UIDataDetectorTypeAll; 自動識別鏈接/電話/日期。txtView.textContainerInset = UIEdgeInsetsMake(16, 12, 16, 12); 內邊距提升閱讀體驗。UITextView + NSAttributedString 分頁加載或 WKWebView 渲染 HTML。長文本賦值:**隱式拼接字符串字面量** 或 **外部資源文件加載**,切勿單行硬寫。修正屬性名 .text,啟用數據檢測與內邊距,體驗即刻提升。