代码笔记读取一段文字
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码笔记读取一段文字相关的知识,希望对你有一定的参考价值。
一,效果图。
二,工程图。
三,代码。
RootViewController.m
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//初始化textView
[self addTextView];
}
#pragma -mark -functions
-(void)addTextView
{
UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 100, 320, 200)];
textView.backgroundColor = [UIColor redColor];
textView.textAlignment=NSTextAlignmentLeft;
NSString * str = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"脑筋急转弯" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
textView.text = str;
[self.view addSubview:textView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
以上是关于代码笔记读取一段文字的主要内容,如果未能解决你的问题,请参考以下文章
solr分布式索引实战分片配置读取:工具类configUtil.java,读取配置代码片段,配置实例