I have editable UITextView that expands as I start writing into multiple rows. At some point the height of UITextView reaches predefined maximum height and becomes scrollable. While UITextView was not scrollable everything looked nice.
When text view becomes scrollable, weird thing starts happening with spellcheck underlining red dots. Details on attached image.
Can anybody help me with this? I'm sure someone has encountered it so far.
It is clearly a bug that was introduced in iOS 7 (still there for 7.0.6).
As soon as you make UITextView scrollable, spellchecker underlines are getting mashed. If you set
textView.scrollEnabled = NO;
then it's fixed.
Solution is to put your text view into scroll view and resize scroll view's content size when text grows.
Here are some screenshots. I've also made views coloured so that you can see the bounds of all text view's subviews. Interesting that with .scrollEnabled set to YES text is inserted in some other UIView which height is being calculated wrong.
.scrollEnabled == YES
.scrollEnabled == NO
Related
Im having trouble resizing content inside static cells to fit different iPhone screen sizes.
Looking at the image below you can see that the UIPickerView and Sign In UILabel both did not resize in width.
I've tried adding code to the ViewDidLoad like so
self.signUp.frame = CGRectMake(0,0,self.view.frame.size.width,self.signUp.frame.size.height);to programmatically adjust their sizes but nothing changed.
I also tried adding equal width constraints to make it match the UITableViewCell contentView width and that did nothing as well.
Same issues happens to all UILabels (Membership,Schedule,Method...) and UITextFields (Comments)
This is all occurring in a UITableViewController.
How can I get it to resize?
Apples freeform UIViewController and UITableView are externally useful in this circumstance.
If you design your app in the storyboard, before applying constraints make sure the UIViewController's size is freeform (big square that doesn't match any screen size).
Then add constrains.
When you run the app, the app will resize properly.
Can anyone point me in a direction to start with the following:
I have five UIWebViews, each of which is correctly sizing to content, inside of a UIScrollView. The UIWebViews display text only and since they are correctly sized to content, do not allow scrolling. I calculate the position of each UIWebView based upon the position and height of the previous UIWebView.
This works fine when all five UIWebViews fit within the bounds of the UIScrollView but I am not sure
How to position them when they exceed the vertical bounds of the UIScrollView
How to get the UIScrollView to actually scroll the contents.
I am working with someone who would like the UIWebViews to be separate controls for subsequent handling - highlighting and some oother functionality.
I have a custom UICollectionViewCell class that sets the background view of the cell to a downloaded image and also a UILabel added to it that sits neatly at the bottom of the cell and is slightly transparent (this label is the title of the image). It looks great in portrait but when I rotate my device to landscape the UILabel stays in its position while the custom cell resizes itself to better fit the screen. I have my UILabel fully constrained to the cell so I don't know why it isn't resizing to always fit the width of the cell whether the device is in portrait/landscape.
I've attached these pictures below to better illustrate what exactly is happening:
I figured it out - for anyone who is also wondering the same thing, this is what I did:
I overrode the layoutSubviews method in my custom UICollectionViewCell class and forced my UILabel to stick to width and bottom of the cell.
It was weird because before I upgraded to xCode 6 and iOS 8 this was working perfectly without the need of this solution (the constraints within the storyboard worked), but now I had to use this approach.
Cheers!
I am trying to initiate a scroll view in my UITextView and even though I seem to have selected the appropriate boxes, I can't seem to get the scrolling working. I have gone through multiple questions similar to this but none seem to have the answer.
I included an image of Xcode below:
Question 2: When I scroll down the majority of my text shows but the scrolling stops with two sentences or so left and I have to scroll down and hold it there to read. Any way I can fix this so it scrolls all the way to the bottom of the text?
Can you check the two boxes: Bounce Horizontally and Bounce Vertically and see what's happening? Sometimes your content are actually way bigger than your view, and they are touching a invisible outer box. If you can see they actually move, that means there is nothing wrong with touch or scroll, is just the view layout problem.
For the content issue, my guess is that the content size is not right, you can programmatically adjust it with textView.frame property, set it to a proper size, such as the frame of the window or the frame of the content, which are CGRect classes. Comment below to see if this can solve your second problem.
The text view will not scroll in storyboard, only the app. And the text view will scroll once the content in the text view exceeds the frame size.
If you're using iOS 7+, you can just turn on auto layout, pin each of the sides of the text view to the edge of its parent view, and it works fine without needing to do anything in code.
I have a view controller with a scrollview with lots of text boxes, when i click on one of the text boxes and the keyboard appears, the content size of the scrollview isn't long enough to show everything with the keyboard open. How can i change the content size every time the keyboard pops up and set it back once it vanishes?
Also is there a method to make it vanish without resignfirstresponder on every textfield?
Hope someone can help me, I'm pretty new to Objective C.
contentSize probably isn't the property you should be changing.
Try changing the frame property of the scroll view (i.e. make it n pt smaller, where n is the height of the keyboard - 216 in portrait, 162 in landscape.)
The scroll view should deal with letting your content scroll correctly after you've changed it's frame.
The content size property is the size of the thing that is being scrolled - this doesn't change, it's just the amount that you can see that has changed.
(If you're feeling flash, you can animate the change in height of the frame :)