Pregunta

I would like to specify a tab length or tab stops when using \t in the function stringWithFormat:

buttonText3 = [NSString stringWithFormat:@"D:\t%ld:%02ld" , hoursAndMinutesDay.hours,hoursAndMinutesDay.minutes];

I have already tried to use a backspace after the tab but this does not work:

[NSString stringWithFormat:@"D:\t%c%ld:%02ld", 0x0008, hoursAndMinutesDay.hours,hoursAndMinutesDay.minutes];

Using a number of spaces instead \t is not an option since the text before \t has different widths depending on the characters.

¿Fue útil?

Solución

There is not. Display of tab characters is outside of NSString's control.

If you are using Cocoa API such as UITextView to display the string, you may be able to use NSAttributedString and NSParagraphStyle to set tab stops for display.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top