读取txt文件

 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];

posted @ 2014-11-24 16:37  銱ル╬鎯噹  阅读(107)  评论(0编辑  收藏  举报