我的代碼編譯罰款,但沒有顯示從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