UITextView don't show text - iphone

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.

Related

UITextfield text is moving on edit

When my UITextField becomes first responder(on edit) the text is moving down very slightly and the spacing between the characters is increased very slightly. Upon resign first responder(keyboard goes away), the characters move back to the original positioning. At first I thought this was a font issue, as I am using a custom font, but the same thing happens when I use the system font or other custom fonts.
Please check the images below. The first one is with the keyboard down and the second is with the keyboard up. It may be difficult to see, as the variance is small, but the keyboard up state shows the characters moved down and apart slightly.
In xib, set textfield's borderStyle to any value than TextBorderStyleNone . And in code, set textfield's borderStyle as TextBorderStyleNone explicitly.
I could'n figure out why but it seems like initializer bug. It works fine in other code which doesn't initialize UITextField by outlet from xib.
When set textfield's borderStyle as TextBorderStyleNone at xib, the problem still remains even if set borderStyle as TextBorderStyleNone in code. It may be followed by some kind of 'layoutIfNeeded' stuff, which triggered by value change.
Selecting the "adjust to fit" property sets the property adjustsFontSizeToWidth in UITextField.
That has this property (UITextField Apple Documentation):
Normally, the text field’s content is drawn with the font you specify in the font property. If this property is set to YES, however,
and the contents in the text property exceed the text field’s bounding
rectangle, the receiver starts reducing the font size until the string
fits or the minimum font size is reached. The text is shrunk along the
baseline.
The default value for this property is NO. If you change it to YES,
you should also set an appropriate minimum font size by modifying the
minimumFontSize property.
I would try first unchecking this and seeing if that would stop it, and then follow the documentation advice and set the minimumFontSize property lower otherwise, which may also be causing the problem.
This issue could possibly be a result of the appearance of the blue "now editing" cursor. The baseline of a text (reference) is the bottom of the text. Your text is shrinking "along the baseline" by pushing down, which leans more strongly in the direction of it being a minimumFontSize/adjustsFontSizeToWidth issue.
If you are forcefully making UITextField first responder, do it in viewDidAppear: instead of viewDidLoad... This solved the problem for me...
Checking OFF the "Clip to Bounds" of textField in my storyboard works fine for me.
You have probably sized your UITextField to be slightly too small height-wise. Try manually resizing it so it's a pixel or two taller. Or select it in the XIB editor and use "Size to fit content" in the Editor menu. That ought to set the text field to the right size so that this text shifting doesn't happen.
Setting the Min Font Size property equal to the font size in Interface Builder worked for me
Changing the vertical alignment under control in the storyboard did it for me.
My issue was connected with wrong alignment of UIStackView.
When you put UITextField into UIStackView, make sure you set its alignment correctly, otherwise auto-layout won't figure out how to position your view right.
In my case, I had to set it to .leading.
stackView.alignment = .leading
You should set Font property earlier than Text property.

Textlabel in tableview cell doesn't resize after refresh

When I initialize a textlabel from a static tableview cell in viewDidLoad, everything is displayed as it should be. However when I change the textvalue some moments later after the press of a button, the text is clipped if it was bigger than the original text set in viewDidLoad. When the new text is shorter, it's being displayed correctly.
Somebody knows a solution for this problem?
-- EDIT --
Solved with:
try calling the label's setNeedsLayout method after changing the text value - that may resize the label. –
Set the adjustsFontSizeToFitWidth property of the label to YES. It will make the font smaller when text becomes longer. Also set the minimumFontSize property to a smaller value than the default.

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.

how to write text on selection indicator of uipickerview

how to write text on selection indicator of uipickerview
The simplest approach will be just to add UILabel with your text over the UIPickerView. You only need to find the right coordinates so text will be placed well.
If you want to display text on it try adding a UILabel as a subview to the view containing the picker. You just need to get the frame in the right spot - easy with IB, more trial and error through code. The set label to have a clear background. Just update the label value as needed.

Changing the text in a UITextView at runtime

I have a ViewController consisting of just a textView. In its viewDidLoad method, I simply initialize the textView and add it as a subview. In my main ViewController class, when the user presses a button, I switch views and display the view that has the textView. I am trying to change the textView's text however it is not working. Can I not change the text of a UITextView at runtime?
Thanks.
You should keep a reference to your text view.
If you do, then make sure that the reference is correct and valid before setting the new text.
In general, it always helps when you post a problematic code - this way it is much easier for us to help you...