In my app I need to show a large volume of data(news) to the user. I tried using UIWebView to show up the news data. It worked fine but the performance was low. UIWebView takes time to show up all the data.
So I started using UILabel to show up the data. This worked fine with no performance issue. But the problem is when ever a line ends the UIWebView automatically puts spaces in between to align the text properly. But UILabel is not doing the same. So the text is not aligned properly. how do we get the text aligned properly as it is done in UIWebView
Thanks In Advance!!!
I think the answer to this is to build your own text layout using UIKit's NSString's extentions: drawAtPoint:InFont as recommended in this SO question.
Try using a UITextView. This should wrap text a little nicer than the UILabel.
Related
I was hoping I can get some help with creating a username and password box similar to the one Yahoo uses on their iPhone app. It seems to have a separator in the single textview box. I'm still new to using Cocoa so I still have a lot to learn.
I have attached an image of the screenshot I took.
Thanks!
Screenshot
The Yahoo screenshot shows what looks like a grouped UITableView with two cells. The separator is the line between the cells, and each of the cells would contain a UITextView.
When displaying a paragraph with some long strings without line breaks in an UIWebView, the size of the character is too small for reading, as show in the following pic. Is there anyway to automatically add line breaks in the long strings as in the UILabel? Thanks in advance!
ps. the UIWebView is used to display an email body.
set the css as : style="word-break:break-all" to solve this problem
Simply NO. UIWebView is made to parse HTML-Markup. The breaking has to be done there. \n will do it.
Other than that, you should rethink your HTML-Box-Model being responsive.
If you only want to display text, then use UITextView instead of UIWebView and switch to UIWebView, if its HTML. I think Mail.app on iOS does it like that. UITextView text is appropriately scaled.
A basic functionality I am trying to implement in UITextView.
I have a text (NSString) and I am trying to place in to the text field as a paragraph (indentation). Is it possible? I have seen many links but none of them have an exact answer.
We have a property named textAlignment but it is for left, right or center not indention.
Can anyone suggest how to implement this?
You should consider using a UIWebView if your displayed text has formatting. Using textViews and labels quickly renders the code to complex.
Possible solution in this post - as the first answer suggested, use a UIWebView.
I've a UITextView, its quiet big, I sized it so it could fit 4 lines of text, so if the user wants to write a long note it can be read while its being written.
The problem is that text stays on the top line and it scrolls horizontally rather than wrapping around and dropping down to a line below it. Like you see when you write a text message on your phone.
Is there anything that can be done to get a UITextField to act like this? Or am I required to use an editable UITextView instead?
Looking at the docs it would seem UITextView cant provide the functionality I need.
Many Thanks
-Code
HI,
I do'nt think , It could be possible by using UITextField (support single line),You will have to use the UITextView (for multiline text) .
See the below tutorial , It grow at runtime while the user type the text using keyboard and can expend till certain line ...
http://www.hanspinckaers.com/multi-line-uitextview-similar-to-sms
If it is an IBOutlet than you can just enable vertical scroll and remove horizontal scroll from scrollers.
Hope this helps.
I have a problem with the text shadow of the UIActionSheet buttons. At iOS 4.0.2 long string were truncated automatically. No at iOS 4.2 these texts are presented with a smaller font. But now the offset of the shadow is corrupted and to big.
Is there a possibility to change/remove the text shadow of the UIActionSheet.
EDIT: I'm building the UIActionSheet not with initWithTitle:, but with the normal init and sets all needed properties afterwards because the number of possible buttons is dynamic and the texts cannot be change. I've tested it with initWithTitle: and got the same results.
You can refer this to truncate your string before displaying it in a UIActionSheet.
I can think there are two workarounds for this (although I would not them myself in my application, reason listed below the workarounds):
In the first case you access the sublayers of UIActionSheet, get the labels, change the shadowOffset and shadowColor before presenting the actionsheet.
Secondly you can initialize the actionsheet with blank titles and add your own labels as subviews on the actionsheet at right places. (More tricky then the first approach).
Now the first approach is very risky as the layer structure of UIActionSheet can be changed by apple in future updates, hence your application may break and would not give good results.
Continuing with second approach is good only when you can calculate the exact frames where you should put your lebels so that they look good. But in your case the number of buttons would also vary, so this approach will take a lot of time initially to get the things working.
Hence, I would go for truncating the strings before I set them as the title of buttons.
Not sure how much would this help. But I am sure that truncating strings before setting them as titles is the best option.
are you doing anything non default for displaying the text?
If you only use UIActionSheet-initWithTitle:… you should write a bug report to Apple.
OR shorten the text to "Frankfurt International (FRA), DE" ;)
This appears to be fixed in 4.30. I found no way of fixing it in 4.2x.