Text not appearing in UITextView in IOS 5.0 and later - iphone

I am working on a iPad application where i am entering some dynamic text into UITextView. It is working fine if i test it on below ios 5.0. But if i test it on ios 5.0 or later, text is not appearing/visible. I have tried with the different font colors too. Any help would be appreciable.
Thanks in advance.

So, I was working on a project and ran into the same thing. In iOS versions other than 5, the UITextView worked perfectly. But, on 5, the text just simply wouldn't show up. I did possibly the hackiest thing ever to fix it. I made the parent view a UITextView delegate, and in the textViewDidChange method of that view, I added the code:
textView.text = [NSString stringWithFormat:#"\n%#",textView.text];
textView.text = [textView.text stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:#""];
This is basically a joke as far as a fix goes. That said, just quickly making it multiline and then single line fixed the problem. I'm quite sure this isn't the correct answer to this problem, but hopefully it helps someone figure out how to handle this in a pinch.

Related

Why is my UILabel not initializing when using another language? (iOS localization)

I'm applying localization to an iPhone app I'm working on, and slowly going through all texts/strings/labels throughout the app to dynamically retrive the correct language translation done through Localizable.strings - I'm testing with two languages to make sure it's working properly. Naturally English, and also Czech.
So far I haven't had any problems until this one particular UILabel.
While using the iPhone and app in English, no problems at all. However when changing the iPhone language to Czech and testing the app, one of my UILabels won't even initialize. It doesn't even matter if I force the text like this:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(#"show: %#", self.segmentedControlTitle);
self.segmentedControlTitle.text = #"test";
// Other code
}
Basically, when in the other language, it just displays the place holder text set in the Storyboard. All other titles that I have set so far work perfectly even using the actual localization method;
- (void)viewDidLoad
{
// The other code...
[self.segmentedControl setTitle:NSLocalizedString(#"VIEWALL_all", nil)
forSegmentAtIndex:0];
}
Any ideas? Can post more code if wanted, but I'm assuming everything is correctly established seeing as though it all works in English. It has to be something simple I've overlooked. I've tried Clean, deleting the app from simulators and my iPhone, trying the build again... same story. Happens on colleague's iPhone as well.
Thanks in advance. (Also I'm still a bit new to iOS dev just FYI)
Dave
Credit goes to Carl Veazey. Your comment helped me figure this out.
So I've learnt the lesson that when you apply localization, you can actually apply it to your storyboard as well - hence creating separate ones for each language.
So my problem was that the English version of the storyboard has the IBOutlet connection, whereas the Czech one did not.
Because I'll be applying all strings like this programatically from the Localizable.strings files, I don't need the storyboard to be localized - I have since removed the Czech version and am applying everything by code. I figure this is better practice anyway.
Thanks again!

Emulating UITextView text rendering with CoreText?

I'm attempting to create a TextView with the ability to highlight various words. I don't want to use the attributedText property in iOS 6 because I want to support iOS 5 and because of other issues (see here for example: UITextView attributedText and syntax highlighting).
So the only option I've got is to use CoreText. I found this project: https://github.com/KayK/RegexHighlightView. What it basically does is overrides the drawRect method of the UITextView and draws the contents with CoreText. The problem is that the Core Text rendering is different from UITextView rendering - which leads the cursor to be in a wrong place (gets worse as the text gets longer).
Is there any hope to fix this issue? Maybe some other clever approach?
Try this:
https://github.com/mattt/TTTAttributedLabel
TTTAttributedLabel supports iOS 4.0 and higher.
Try EGOTextView. Or you can do the webView way. (UITextView actually does this under the hood mostly)

UILabel's new text get's combined with previous text when testing on real iPhone 4

I have some UILabel objects in my app, and I change their value when a button is pressed. It works fine in the simulator and on old iPhones, but If I try it on an iPhone 4, the previous text of the label doesn't disappear, it shows behind the the new text (well, sometimes it disappears and only the correct text appears, but most of the times it doesn't work right).
This is the code (it's a method that only does that, lehenPantalla is a UIViewController, and the variables used to set the text are ints passed as parameters):
self.lehenPantalla.firstPlayerSet.text = [NSString stringWithFormat:#"%d",localFirstPlayerSet];
self.lehenPantalla.secondPlayerSet.text = [NSString stringWithFormat:#"%d",localSecondPlayerSet];
self.lehenPantalla.firstPlayerGames.text = [NSString stringWithFormat:#"%d",localFirstPlayerGames];
self.lehenPantalla.secondPlayerGames.text = [NSString stringWithFormat:#"%d",localSecondPlayerGames];
Is this a common error? I don't know if this happens because the phone is an iPhone 4 or because it's using iOS 5.1 (the other phone is running iOS 4).
I experienced the same problem with iPhone4/ios5. At the end just making the label non-Opaque (unchecking the Opaque checkbox in interface designer) solved the issue. Where I wanted this label to draw upon the background (with no transparency) I just had to put another label beneath it (same width, no content). Hope that might help.
Given this sounds like it is appearing in ios5 and not before, perhaps it is related to view controller containment which changed in ios5. Events such as viewDidLoad/willAppear etc aren't necessarily called properly without proper containment.
Have you called addChildViewcontroller to add lehanPantella?

UITextField background behaviour change from iOS 4 to iOS 5

In my app I have a UITextField which is on top of a background image. Under iOS 4 I had to set the backgroundColor property to 'clearColor' in order to make it look right. Under iOS 4 the textfield looks like this...
This is how I want it to look. Now, since upgrading to Xcode 4.3 (iOS 5) when I re-run the same project, the box looks like this...
Grrr. So under iOS 5 I changed the backgroundColor property to 'whiteColor' and it works fine. However now, under iOS 4.x the box looks like this...
Note the ugly white corners! So please, can anyone tell me what I should be doing here in order to get it to look normal under both iOS 4 and iOS 5 (i.e. To look like the first image!).
Many thanks,
Simon
I got the same problem a few days ago. To solve this, I just set the borderStyle and comment the backgroundColor line. Everything just work fine, both iOS4 and iOS5.
// textField.backgroundColor = [UIColor clearColor]; // just leave it, dont't set
textField.borderStyle = UITextBorderStyleRoundedRect;
This is what i did to resolve this issue, you can check the version of iOS running on the device and do the handling accordingly, like this
float version = [[[UIDevice currentDevice]systemVersion]floatValue];
if(version < 5.0)
{
//user clear color
}else
{
//use white color
}
Hope this helps you.
Sometimes you might have to rebuild your project. Also, try and make this in a whole new project to see if it is actually a new change to Xcode, or if it is just that particular project to narrow things down. If you then isolate it to being something wrong with your particular project, try and "do it over" to see if it clicks then. But i see you solved it :=)

UILabel text on iPad not resizing

I have iOS 4.3 installed on my iPad. I'm noticing that my text in my UILabels is not resizing. In other words, I'm adding letters, but it's just truncating. Same settings work find on iPhone also running 4.3. I'm perplexed. I've made certain that "Adjust to fit" is checked on the label properties. I've even set it in the code with .adjustsFontSizeToFitWidth and even tried calling sizeToFit.
None of these let the text resize.
Does anyone else have this problem?
Any ideas?
My next solution is going to use this: Check if label is truncated to try and manually resize the label text.
I finally figured it out. I'm using OHAttributedLabel. I had intended to do some things with color in my labels and have not yet gotten around to it. It finally dawned on me that was the only difference from previous iPad versions and from the iPhone version (I never even thought to look at the class). Turns out this OHAttributedLabel class does not support resizing yet.
Sorry for wasting everyones time. Maybe someone else will someday find this useful.
Try using CGSize eLabelSize = [yourLabel.text sizeWithFont:yourLabel.font]; to get the size of the label and then you can simply modify the yourLabel.frame.size property with eLabelSize.
This worked for me in case of iPhone.
Hope this works for you if yes do communicate..... :)
Maybe it only appears as if the label is truncating text because the label frame runs out of the bounds of its parent view, which clips to its bounds? Verify the frame of the label and the autoresizing mask.
Also, the minimumFontSize property is set low enough?