NSString with \n or line break

前端 未结 10 817
生来不讨喜
生来不讨喜 2020-12-04 11:15

Does anyone know how to use line breaks in NSString? I need to do something like this -

[NSString stringWithFormat:@\"%@,\\n%@\", mystring1,mystring2];
         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 11:48

    In case \n or \r is not working and if you are working with uiwebview and trying to load html using < br > tag to insert new line. Don't just use < br > tag in NSString stringWithFormat.

    Instead use the same by appending. i.e by using stringByAppendingString

     yourNSString = [yourNSString stringByAppendingString:@"
    "];

提交回复
热议问题