UITextView with 3 lines automatically scrolls up when I enter <screen capture> - iphone

I have a UITextView that i use for typing some text
(i have added it with Interface builder)
i have made the height 3 font lines high (so in my case the frame height is 47) so i can have 3 lines of text
what i want it to do is type until line3 and the go up if i goto line 4
but what it does is whenever i type enter it automatically goes up so i'm constantly typing at the top of my uitextview
ive put a capture online that show it more cleary .. even when i click a line it goes to the top!
Click here for the screen capture

Write [textview setContentInset:UIEdgeInsetsZero] in textviewbeginediting delegate method or either at the ViewDidLoad method
Hope this will help you.....

It looks like the trick is to make the font size bigger
txtView.font = [UIFont systemFontOfSize:14];
when i make my font size 2 points bigger it just types normal instead of going up every line.

I struggled with this for weeks and finally found out that all I had to do was to set the UITextView height to double (or whatever you want), set its background color to ClearColor and you are all set. You just have to play with the height and you will get it. In my case the UITextView was in a tablecell..first when I increased the height it started showing on top of the cell below the current cell. Thats when ClearColor did the magic 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.

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.

How to make UILabel wordwrap

Is there anyway of making a UILabel wrap to the next line or do I have to use a UITextView?
You would need to set the numberOfLines property to 0 and explicitly specify its dimensions, either in IB or programmatically. However, if you have a lot of text to display, I would recommend using a UITextView.
What you want is to adjust your label according to the content's size.
In iOS 6, AutoLayout will work a charm, you should set the label to have numberOfLines = 0
In a non AutoLayout scenario, you will also want to make sure the frame of your UILabel is adjusted to show the content that's on the next line.
Please check out this answer and sample code for that: https://stackoverflow.com/a/8796896/662605

Resize UILabel text with swipe to delete

I am having some trouble getting my application to properly resize the text of UILabels when the user does a swipe to delete or other type of delete. Currently, the delete button is covering up the text that is in the cell (if it is really long). I would like for them to operate like how SMS (move clipped text down a line) or iPod (delete button resizing text).
I am using a custom UITableViewCell I am working with two labels, UIImageView and a couple of subviews for backgroundView and selectedBackgroundView. I have been playing with the springs and struts of the labels in the cell and partially attained my desired effect however, the text has a weird, quick resizing bug where it becomes deformed and stretched out and then is returned proper size when the delete button is done animating.
As far as other things that I have tried, I have made sure that my text does not adjust-to-fit and I have made my minimum font size the font size that I set for the label. I have also tried over-riding layoutSubviews but that didn't seem to have any effect at all.
If a screenshot (of the deforming label) or code would be helpful, I can post both but since nothing I have done is working, I figured they would be of little value.
fixed it by setting the "mode" of the label in the view panel to "left"
It sounds like you need to set the number of lines property and the wrap property for the labels.
If your actively changing the size of the label itself, you might want to animate that change.

UITextView Paging Enabled Text cut off

I am using a UITextView and enabling paging (in both IB and programatically toggling it on and off). There's a lot of text and when scrolling with paging enabled sometimes the first and/or last line of the currently viewable text ends up halfway in view and half out of view at the bottom or top of the frame so you can only see the top or bottom half of that line of text.   (I hope I'm explaining that correctly)
Does anyone know a way to insure that it pages correctly so it there's no lines of text half cut off?? 
A few notes
1. The font size is adjustable by the user.
2. I've tried setContentOffset,setContentInset,setContentSize and it's not helping (unless I'm using them wrong)
3. I am using a txt file to populate the UITextView
Thanks in advance!!
UITextView is a subclass of UIScrollView. As such I do not believe UITextView actually supports paging as this is a feature of UIScrollView. Can you please take a step back and explain the end goal, as it sounds like rendering an NSString in to a UIScrollView might be actually what you want, instead of a UITextView.