how to make content of NSString goes to next line based on \n on iphone
i have a NSString s=@"hi\nhello\n\nwelcome to this world\ni m jhon"
now how to display this content in UIlabel so that \n allow 1 line gap and \n\n allows 2 line gap
still i am getting same value
NSString *s=aDl.content;// aDl.content=hi\nhello\n\nwelcome to this world\ni m jhon
labelb.text=s;// its same without line break :(
kindly help me 开发者_如何学编程
Thanks
Set label's height big enough to accommodate all lines in your string. Then set label's numberOfLines property to 0 - so label will draw its text in as much lines as required. New lines symbols (\n) will be handled by label automatically:
NSString *s=@"hi\nhello\n\nwelcome to this world\ni m jhon"
label.frame = ...//big enough height
label.numberOfLines = 0;
label.text = s;
精彩评论