UITextField placeholder text position wrong when right aligned and orientation changed - iphone

I'm not sure if I've found a bug or missing some intricate setting in the iOS SDK.
I have a UITextField with right aligned text and some placeholder text. I've set it to autosize when switching from portrait to landscape (IB settings are like this: http://db.tt/laTmXIS ).
When in Portrait, it all works as expected: http://db.tt/skf8wqN However, after rotating the placeholder text is in the wrong place: http://db.tt/7pU5kdR
It looks to me that the autoresizing properties are not replicated into the placeholder text UILabel subview.
I've replicated this in a new project (download here: http://db.tt/OSnvv2Y), so it's nothing funky in my code as far as I can see.
Any ideas?
Update: Dan's workaround fixes this. Add an IBOutlet connected to your textField and then add this code to your UIViewController...
- (void)didRotateFromInterfaceOrientation:
(UIInterfaceOrientation)fromInterfaceOrientation {
textField.textAlignment = UITextAlignmentLeft;
textField.textAlignment = UITextAlignmentRight;
}

i set it to left and then center in same function upon rotation, that seems to fix it until they fix the bug! :)

This appears to be a bug in UIKit. Please file a bug report, including this sample project and images. It'd be nice if the sample app worked for both iPhone and iPad.
I agree that the text should stay flush with the right edge of the textfield.

Related

UIButton not Changing Length in Different Language

I have developed an iOS app that I have localized in both French and English. I have a UIButton in my UINavigationBar that reads Back in English and Retournerin French. My UIButton seems to just take the length from the English button as default so when the app is opened on a French device the text doesn't fit in the button.
I've tried having the UIButton read Retourner in my Storyboard and I can't seem to set a constraint for the length. Am I missing something?
Try this then
button.titleLabel?.adjustsFontSizeToFitWidth = true
Found in: How to adjust font size of text in a UIButton to fit the width programmatically in Swift?
Well it turns out theres a provided method for this!
I just set:
backButton.sizeToFit()
In my viewDidLoad and it worked like a charm.

UINavigationBar title gets truncated when using custom font

after using this code to custom the UINavigationBar title appearance, the label with text gets truncated, as the image below shows:
[[UINavigationBar appearance] setTitleTextAttributes:#{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeFont : [UIFont fontWithName:#"Intro" size:20.0f],
UITextAttributeTextShadowColor : [UIColor clearColor]
}];
And, as you can see, there is enough space.
Any ideas?
Update for iOS 9
I've done a fair bit of testing in a clean project with a few dozen built-in fonts at various sizes, and I think I can state with some confidence that the label sizing issues found in earlier versions of iOS have been fixed in (or before) iOS 9.
The use case decribed in the original question does not seem to be reproducible, and the title label now seems to resize properly on its own. As such, I don't think it's necessary to update the layout manually anymore.
If you are still seeing truncation issues when there is clearly plenty of visual space available in the navigation bar, there are a few things you could try:
Remove any extra views that you may have been using to workaround the issue. For example, if you are creating your own UILabel and setting it as the navigation bar's titleView, you can stop doing that, and just set the title normally.
Remove as much code as possible that adjusts the sizing of the navigation bar and titleView. That includes the code found in the originally accepted answer below.
If you are using a custom font (i.e., one not included with iOS), validate it to make sure that it is not damaged, and contains all of the metadata necessary for iOS to measure it properly. If a font is damaged, it can appear incorrectly when used.
Original Answer
There are some known issues with UINavigationBar layout. Try updating the layout when the view controller appears, and/or on rotation.
- (void)viewDidLoad
{
[super viewDidLoad];
...
[[[self navigationController] navigationBar] setNeedsLayout];
}
You might try making aUILabel with a clear background color and your desired text settings. You can then set this label as the titleView attribute of your UINavigationBar
I had the same problem if I first initialized the title to an empty string, then later tried to update it. Calling setNeedsLayout did not fix. Initializing the empty title to 20 space characters solved the problem for me.
After you set the label call
label.sizeToFit()

UITextView don't show text

I have a TextView in my xib file.
After I assign text for it, it doesn't show the text till I double click it, and actually change the selection of the text:
Before double click:
After double click:
After changing selection size:
Do you have any idea, how to show text from the beginning?
Thanks
We found the solution. This situation happens, when you try to update the txt before the view is visible.
We override the function viewDidAppear, and did this code:
// To fix the bug of not showing text in textView
self.txtViewShowDetails.text = nil;
self.txtViewShowDetails.text = self.mediaItem.mediaDescription;
[self.txtViewShowDetails setContentOffset:CGPointZero];
If the view is animated, or inside animated controlView, we have to call the viewDidAppear after animation finished.
I had a similar bug, but it happened when I made the text unselectable. Once I made it selectable again(checked in nib), it fixed the text again. While this isn't a solution to this bug (unless making it unselectable also fixes your problem), hopefully it will help others.
think you have set TextView custom font in IB .so you need to set custom font in code.Please set system font in IB and check in both device
TextView.font=[UIFont fontWithName:#"HelveticaNeue-Medium" size:17.0];
In my case text was long and it was trimming from end. I was setting text first then font and colour. I Set font first then text. It works for me.

View come up on the keyboard window. How to solve it

I have list of the text filed in vertically. And all these are in one UIViewController and I am adding this UIViewController's View in my another class.
When I clicked on the text filed keyboard appears. And that scroll view comes on the keyboard window. How can i solve this. I am beginner and no idea about this problem.
Also when I open the UIPopover with date picker. And when I scroll the date picker for selecting the date the UIPopoverController also change in their layout.
Also I have attached the some screen shoot for better understanding of issue.
Got Answer
Thanks for your help. Solved my issue. In my demo code i have change some property of the UIView's Layer. For setting border, cornerRadius.
One More property i have set is "[self.view.layer setClipsToBounds:YES];". I don't know what is wrong in this but when i remove that line code just work fine.
But this property work fine with UIImageView.
Just comment below line from PaymentView.m file - (void)viewDidLoad method
[InnerView setClipsToBounds:YES];
Your question is not very clear with text,put some code.
However seeing the images in red block a suggestion could be reduce the y-axis of the y axis of your view which is coming over the keyboard.

White Line at bottom of UITableView Cell at end of section in Grouped TableView (iOS 5)

I have noticed a change in the look of the tableview cells in iOS 5, and I googles around a bit to see if anyone else had noticed. This fellow did, and posted this image. I can't reproduce it on every uitableview (if I could I would know where it came from and I could get rid of it), but it is certainly causing me a problem on one of my tableviews. Has anyone else noticed this - better yet, has anyone else found a way to get rid of it?
I had this issue, on an iOS4 phone or simulator it looks fine but for iOS5 it was a problem. I discovered that the issue was with the separator style for the table view. It looks like the default value is set to etched for iOS5. I have gone through my code and added the following line to my init method for all grouped table view controllers:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
Which has fixed the issue for me, although I also set the following as the color appeared to be white not grey as in the previous version:
self.tableView.separatorColor = [UIColor lightGrayColor];
It was a problem for me as I have changed the background on all of my table views and the extra line didn't look good for my app.
use:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;