Pregunta

Tengo la necesidad de mostrar texto que incluya etiquetas HTML, etc. y ttstyledTextLabel se ajusta a la factura ..... pero no se desplaza.

Coloqué uno dentro de UITextView pero esto se niega a desplazarse? Si ingreso el texto directamente en UITextView, se desplaza bien, pero veo todo el HTML sin formato.

¿Hay alguna forma de establecer ttstyledTextLabel para desplazarse?

Gracias

¿Fue útil?

Solución

Intenta poner el TTStyledTextLabel en un UIScrollView.

Alternativamente, puede considerar usar un UIWebView directamente.

Otros consejos

Finalmente obtuve un trabajo adecuado ...

CGSIZE CONSTRINIA DELIZA;

CGSIZE Stringsize;

// hacer una asignación de tamaño demasiado grande

restrictsize.width = 300;

restrictSize.Height = 2000;

Nsstring *s = @"Esto puede ser un texto tan largo o tan corto como sea necesario ...;

Uifont *f = [uiFont fontWithName:@"Arial" Tamaño: 14];

stringsize = [s sizewithfont: f restrictedTosize: restrictsize linebreakmode: uilinebreakmodewordWrap];

// crear una etiqueta para acomodar el texto

Uilabel *l = [[uilabel alloc] initwithframe: cgrectmake (14, 2, stringsize.width, stringsize.height)];

l.text = s;

l setNumberOfLines: 0];

l sizetOfit];

// ahora crea un ttstyledTextLabel para que coincida con el tamaño que acabamos de obtener anteriormente

TtstyledTextLabel *tl = [[ttstyledTextLabel alloc] initwithFrame: [l marco]];

// Establecer el texto haciendo uso de enlaces, etc.

tl.text = [ttstyledText textFromXHTML: L.Text LineBreaks: Sí Urls: Sí];

TL SECUPTACEGROURTColor: [Uicolor ClearColor]];

tl.TextColor = [UICOLOR WHITECOLOR];

UIScrollView *sv = [[UIScrollView Alloc] initwithFrame: cgrectmake (0, 185, 320, 300)];

// Ajuste el tamaño del contenido de ScrollView para acomodar el ttstyledTextLabel

sv setContentSize: cgsizemake (tl.frame.size.width, tl.frame.size.height)];

sv addSubView: tl];

self.view addSubView: sv];

Ahora puedo tener un tamaño automático ttstyledTextLabel que se desplaza ;-)

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