我的工作是加载csv文本" FLYING TO POINT"和concat整数1,因此显示在UILabel上。
当我使用iphone 6,ios 9.2运行以下方法时。它只显示字母
你能告诉我该怎么办?以下是我的工作:
lblDConnectStatus = [self constructLabelT: _labels[40] :
CGRectMake( 0 ,
(demoViewLeft.frame.size.height - imageMenu.size.height)*0.15 ,
demoViewLeft.frame.size.width * 0.9 ,
demoViewLeft.frame.size.height ) :@"#fff" :12 :@"TitilliumText22L-Regular"];
//
[lblDConnectStatus setTextColor:[UIColor whiteColor]];
[lblDConnectStatus setTextAlignment:NSTextAlignmentCenter ];
[demoViewLeft addSubview:lblDConnectStatus ];
NSString *cString = [NSString stringWithFormat:@"%d", 1];
lblDConnectStatus.text = [NSString stringWithFormat: @"%@ %@", _labels[180] , cString ];
- (UILabel *) constructLabelT:(NSString * )content : (CGRect) pageFrame : (NSString * ) colorHex : (float) sizeX : (NSString * ) fontStyle
{
UIFont * customFont = [UIFont fontWithName: fontStyle size:(sizeX*self.view.frame.size.width/375)]; //custom font
UILabel* label = [[UILabel alloc]initWithFrame: pageFrame ] ;
label.text = content;
label.font = customFont;
label.adjustsFontSizeToFitWidth = YES;
label.clipsToBounds = YES;
label.textColor = [self colorFromHexString:colorHex];
label.textAlignment = NSTextAlignmentLeft;
return label ;
}
通过csv获取String的方法:
- (NSMutableArray *) readCSV: (NSString *) flag
{
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"novax_en" ofType:@"csv"];
if([flag isEqualToString:@"de"]){
filePath = [[NSBundle mainBundle] pathForResource:@"novax_de" ofType:@"csv"];
}
NSError *errorReading;
NSLog(@"filePath %@",filePath);
NSString *fileString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&errorReading];
// NSString* str = [[NSString alloc] initWithData:fileString encoding:NSISOLatin1StringEncoding];
if (!fileString) {
NSLog(@"Reading error %@",errorReading);
}
NSArray *linesArray= [fileString componentsSeparatedByString:@"\n"];
return [linesArray mutableCopy];
}