Fas*_*ser 2 cocoa-touch objective-c line-breaks paragraph ios
是否有一种方便的方法来格式化一个相当长的字符串,其中包含段落(如下所示)以便在其中使用\n
它,因此textView也会显示段落?
blah
blah
Run Code Online (Sandbox Code Playgroud)
至 @"blah\n\nblah"
谢谢!
小智 5
这是一个简单的例子,假设你有:
在文本文件中写下您想要的任何内容,并将其放在Xcode项目中的任何位置(通常从"Ressources"下的Xcode中导入),然后在代码中的某处(init方法或操作):
NSString *path = [[NSBundle mainBundle] pathForResource:@"myfile"
ofType:@"txt"];
NSString *content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:NULL];
textView.text = content;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1520 次 |
最近记录: |