UITextView only displays first line of text - ios

I have a UITextview. It has enough text in it that it flows into multiple lines. However when I run the app on a device, the text does not flow onto subsequent lines, it's as if the text is carrying on beyond the bounds of the view.
All the settings for the view are the default, but user interaction is disabled. The view has constraints which bound it to the margins of the viewport. I've coloured the background of the view to check this - the view is not running off the edge of the viewport, and has sufficient height that the 2nd and 3rd lines of text should fit on the view, but below the first line of text the view is empty.
What is going on?

Related

iOS: How to display a box of 'tappable tags'

My use-case is like this:
The user defined some tags (text like "#asdf", "#qwerty", "#let_me_think_about_it" and "#decide later"). I want to display these in a box without scrolling (and don't know, how many tags the user created until I display the box).
The box itself should not be scrollable at all but be shown in a UITableViewCell (which is being scrolled). So it must compute the proposed height and respond to Autolayout mechanisms. If a (ARM) Mac user resizes the window to be smaller than before (or an iOS user rotates the device), the box should increase/decrease its height, as necessary (within the limits of Autolayout, since I know of some issues). Each of the tags should be (de)selectable at the same time (UILabel with UITapGestureRegognizer attachted?) and be able to displayed 'selected' (via a background view).
So, the box should primary try to align all content horizontal. If There's not enough horizontal space, do a "line break" and continue on the next "line".
My current solution is a UIScrollView that the user can scroll horizontal and tap any of the (UILabel) views. The displayed views itself are being loaded from a NIB file, like a UITableView does. The issue here is that not any of the selected tags might be visible at the first glance.
If there was no Autolayout, I'd exactly know what to do. But since there it is, I want to use Autolayout in my NIB files and wonder what you would do?
(How do you compute the required width of such a view and decide when a line break is to be done (and how?))
I think I need a simple hint. But if it needs code to explain, ObjC and Swift is both acceptable. :-)
So, the box should primary try to align all content horizontal. If There's not enough horizontal space, do a "line break" and continue on the next "line".
This sounds like a job for UICollectionView with UICollectionViewFlowLayout. You can disable scrolling, and the layout object will tell you the size of the content so that you can adjust the size of the box.
(How do you compute the required width of such a view and decide when a line break is to be done (and how?))
If you're doing it yourself, you add up the widths of all the items on the first line, and if it's larger than the available space, you move the item that extends past the limit and any subsequent items to the next line. Repeat as needed. But that's exactly what a flow layout does for a collection view, so there's no need to roll your own.

Jenkins text not auto-wrapping (causes text field stretching)

The text fields for some of the jobs have stretched beyond the screen bounds. It's still possible to see the text but scrolling is required (annoying).
The effect happens when only one of the text fields contains text that exceeds the normal screen bounds.
Instead of wrapping to the next line, the text keeps going and takes the screen bounds with it.
These screenshots show what's going on:
Is there some sort of configuration that I need to do to make this useable?
The Jenkins version is 1.635

Scroll back to top in iOS UITextView after change of text

I have a UITextView. The text in the view keeps changing based on user action. On many occasions, the text is too large to fit and so my text view (which has a desired fixed width and height) scrolls the text. The control flow is something like this
1) user takes some action, and text view appears with some text (possibly more than what can fit, so comes with a scroll)
2) user dismisses the view (I simply hide the text view)
3) user another action, and text view appears with new text (i use UITextView setText to reassign the text, and simply turn the hidden property to NO)
Problem Scenario:
Perform step 1 above, user scroll down a little to read the content, then proceeds with step 2 and 3. But when the text view reappears, the view is still scrolled a little from the last interaction. I want the text to be visible from the start, meaning, the scroll shud be "reset"
What I tried:
[textView scrollRangeToVisible:NSMakeRange(0,0)]; //OR
[textView scrollRangeToVisible:NSMakeRange(0,600)]; //600 being an approximate number of characters that can show in my text view after which they flow out and it has to be scrolled.
this was the most successful attempt. Worked most of the time, except, sometimes, intermittently, there would be a lot of extra space on top of my line 1 of the text, like someone scrolled/swiped it down and froze it there.
PS:My text cannot be edited by the user. It is always reset to a different string in code

Creating an animation such as iOS 8 Weather App

I want to create a view in which I like to have animation such as the one present in iOS 8 Weather app.
I try to explain more what I have done. If anything is incorrect please guide me.
In the top I put a label for the temperature. (The big one)
Below that label, I put another label to show some text. In the Weather app, there is the horizontal scrollview showing the hourly forecast.
Next is the Table view.
What I want to achieve is that when I start scrolling, the first label disappear smoothly and the second one go to top of the screen and the TableView stretches to show more content.
When I scroll back to the top, I want the whole process to revert.
What is the best way to do this?
I've recently re-created the iOS8 Weather app's scrolling effect for an app I'm creating.
The complete code is too long to post here but for anyone who's interested, I've put it on GitHub. You can download and run the project to see how it looks. Improvements to the code are welcome:
UIScrollView with masked content.
It works like this:
You have one scrollview (the size of the screen), which contains a subview (the mask) which in turn has a subview (the content). We also add a large label to the top of the screen (in the Weather app, this displays the temperature).
Then you use the scrollViewDidScroll delegate method to keep the mask fixed to the screen as the user scrolls. You also use this method to stretch the mask upwards at first.
Fixing the mask to the screen means that the mask's subviews (our content) also becomes fixed. But we want it to scroll, so we do the opposite to the content of what we did to the mask (again, using scrollViewDidScroll).
We need the mask to actually behave as a mask, so we set clipsToBounds = YES on the mask.
Finally, we use the scrollview's offset during scroll to move and fade the big label at the top of the screen.
To make it behave exactly like the iOS8 Weather app, we need to also do the following:
Cancel any scroll touches that happen above the mask, i.e. over the large temperature display.
Ensure that the initial scroll that moves the temperature display is completed programatically if the user doesn't complete it.
Add a sideways-scrolling subview which is anchored to the top of the mask.
I haven't done these yet, though.

How to ensure that only a certain section of a UIScrollView appears to slide?

I use a UIScrollView that has horizontal sliding enabled.
The Heading of the scroll view is Instructions for Using this App
And below that, I have instructions, one instruction per "page".
When the user scrolls horizontally, new instructions show. However, during this horizontal scrolling, the "Instructions for Using this App" from the second page also appears to move.
Instructions for Using this App <--- I do not want this to appear to slide
1. Instruction number 1. XYZ...
more text more text more text
more text more text more text <--- I want only this to slide
How to achieve this?
You can place separate UIView (probably UILabel in your case) on top of your UIScrollView, so your UI hierarchy will be something like:
UIView (screen)
UILabel (header)
UIScrollView (scrolled content)

Resources