我的代码编译罚款,但没有显示从mathspractice.txt从NSArray的到的UILabel
-(void)loadText
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *textFilePath = [bundle pathForResource:@"mathspractice" ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath];
NSArray *mathsPracticeTextArray = [[NSArray alloc] initWithArray:[fileContents componentsSeparatedByString:@" "]];
self.mathsPracticeText = mathsPracticeTextArray;
[mathsPracticeTextArray release];
}
和文本:
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,100,960,40)];
myLabel.text = [mathsPracticeText componentsJoinedByString:@" "];
[myScrollView addSubview:myLabel];
[myLabel release];
谁能告诉我为什么?
回到你检查,以确保文本被正确地加载到mathsPracticText? – kubi 2010-02-24 17:11:52
什么是mathsPractiveText?另外我没有看到分割文件的目的,如果你只是稍后再加入它们 – 2010-02-24 17:20:25
Duplicate:http://stackoverflow.com/questions/2327656/parsing-txt-from-array-to-uilabel – 2010-02-24 19:03:21