How To append CRLF in my UILABEL
I am displaying text on a UILABEL from XML, I am getting CRLF's in the text.So i am not able to append the new lines for my label.This is the code i tried.But iam not getting PLease help me in this
NSArray* array = [subHead.Description componentsSeparatedByString:@"\r\n"];
NSLog(@"Count : %d",[array count]);
for(int i=0;i<[array count];i++)
{
NSLog(@"%@",[array objectAtIndex:i]);
NSString* s = [NSString stringWithFormat:@"%@",[array objectAtIndex:i]];
// s = [s stringByTrimmingCharactersInSet:[NSCharacterSet controlCharacterSet]];
if ([s length]>0){
[str appendString:[array objectAtIndex:i]];
[str appendString:@"\r\n"];flag++;
}else {
NSLog(@"Two \n\'s are occured");
}
NSLog(@"Flag 开发者_如何学Cvalue : %d",flag);
}
NSLog(@"String : %@",str);
NSLog(@"Description : %@",subHead.Description);
subheadlabel.text=str;
THANKS IN ADVANCE
set yourLabel.numberOfLines = 0;
follow How to add line break for UILabel? link you will get idea how it works.
This should help you.
精彩评论