In my app I have a UIScrollView with not many subviews that doesn't use Auto Layout but rather plain old Autosizing to fill itself to the size of the view controller. The only line of code that interacts with it is this:
settingScrollView.contentSize = CGSizeMake(320, 600);
The problem is that only on the iPhone 4/4S, it does this skip sort of thing when you reach the bottom of the scroll view. Here is a video of what happens.
Is this a UIKit bug or am I doing something wrong?
The problem seems to be a bug with iOS 7. This was a scrollview in a scrollview which, while I know is not best practice, worked just fine on the iPhone 5/5S form factor it had the strange behavior mentioned above on the iPhone 4/4S. Moving the daughter scrollview out of the parent scrollview and having it move as though it were in the parent scrollview.
Related
I have a ViewController with a hierarchy as follows:
UIViewController
UIView
UIScrollView
UIView
UIImageView
UILabel
The layout is such that the UIScrollView fills the screen. There is no extra logic executed on this ViewController, such as programatic scrolling, listening to scrolling, etc.
When I run this on an iOS 9.0 simulator, the layout is correctly inflated, with the UIImageView drawn flush against the top margin.
But when I run this on an iOS 9.1 simulator, there is initially a large whitespace between the top margin and the image. Upon touching the UIScrollView it corrects itself, scrolling that the UIImageView is flush against the margin.
Setting automaticallyAdjustsScrollViewInsets does not have an effect (presumably because the scrollview isn't at my root).
My question is: What is different about iOS 9.1 scrollviews that it would be causing this, and what is the work around? Its bothering me since this isn't exactly a complex layout I'm trying to use.
Edit
Screen shot of my hierarchy and the constraints applied to them, maybe it helps.
I think the issue might be the hight constraints. try getting rid of them and add them back in, one at a time as needed.
In my app, I am using standard xib files rather than a storyboard and all of the views have the universal size class option selected. When I do the design work, I always work in the any.any frame.
All views are set to use auto layout and size classes.
For just about everything, this works a treat.
The problem comes if I have a UIScrollView in the view. It looks fine in any,any and when I move to compact,any the view looks fine with everything in the right place.
However, if I then test on the device, the scrollview is much larger than the device view, so something has gone amiss.
Adding in scrlView.TranslatesAutoresizingMaskIntoConstraints = true; sorts the problem for the scrollview, but then messes up the rest of the view outside of the scrollview.
The scrollview is set to have scrolling enabled and bounces. Everything else is as it comes when you add the scrollview.
It looks as if the scrollview (on deployment) is set to still be any,any rather than compact,any.
Is there a way to fix this?
I have a UITableView in a UIViewController which is inside a UINavigationController which is inside a UITabBarController.
When Developing using a 3.5" Simulator and having my storyboard set to 3.5" and everything works fine.
However if I use a 4" simulator, the UITableView ends too short up the screen. And if I do it the other way around the table view ends off the bottom of the screen.
How do I go about correctly sizing my UITableView?
(P.S. I'm not sure it matters, but I'm loading an AdBannerView which goes at the bottom of the screen, so I'm adjusting the contentInset of the UITableView after it is loaded to make space for the AdBannerView, but I don't think that makes a difference to this situation).
You need to add auto layout constraints so that the components are resized according to the desired logic.
Read Apple's Auto Layout Guide and you'll know everything you need in order to accomplish this.
I have designed my app for 4inch devices using xcode 5 and storyboard builder. Since the 3.5inch screen is a little bit smaller, I want to make my view scrollable.
This is what I have done: I added a ScrollView using interface builder and added my View (that contains all elements) as a subview of it.
I start the app using the 4inch simulator and it does not scroll - exactly what I want. But when I open it with the 3.5inch simulator my content gets cut and scrolling is not possible. Why? And how can I activate it?
have you implement the UIScrollViewDelegate Protocol
Do you use Autolayout?
You also want to make sure your scrollview's contentSize is set to your view's size.
I have a problem adapting my apps to the new iphone5 layout, I've made the following passes:
Added a retina 4" splash image
Modified the interface in my storyboard with "Size inspector" to change the anchoring of the widgets
Tested the app with iOS6 "retina 4" simulator.
The app works as expected except when the user pop up the keyboard to edit a text, I use the "stretching scrollview" method for this particular situation and this seems not compatibile with the "autosizing" properties of my widgets, here is an example, from iOS6 simulator, without and with keyboard:
And here is what happens:
I'm quite sure this is a coherent behaviour since my main view is stretched so the other items inside it are stretched following their anchoring, the fact is that I'd like to have the same behaviour of my previous fixed position (all widgets anchored to the top left corner) with the iphone5 gui expansion, is this possibile?
How do you solve the problem of showing a keyboard and scroll hidden content in an iphone 5 compatible way?
I have been having similar problems. From what I have found thus far, we may need to remove all constraints on the view within the scrollable view, because it appears that it's contents are being resized along with the frame of the scrollView. I know that setting the internal view's frame manually in viewWillAppear will work, but then you are stuck having a view that is the same size for both iPhone4 and iPhone5 (albeit it will scroll). Or you could "pin height and pin width" of the internalView right there in storyboard.
Two potential approaches that may work. Sorry I can't confirm these as I'm giving up and redesigning around this problem.
1. Programmatically add constraints to your internal view's subviews. The programmatic constraints will allow you to "spring" the distance between your elements proportionally. When adding constraints programmatically, you are given access to a factor called "multiplier" (not to be confused with priority), which I saw someone else on stackoverflow posting about.
2. You can design the internalView in Interface Builder as a separate viewController with it's .xib file, and then use storyboard to load it as an embedded viewController to a "containerView" object, which you would put in place as the new "internal view" of the scrollView. Perhaps then the .xib would first resize to the correct iOS device, and then you could use its frame to resize the containerView.
My advice is create a small test-case of these before implementing, else you end up like me, having spent hours down the wrong path and facing a dead-end.
UPDATE 12/4/12
Make your life easier by NOT setting the ScrollView as the main view of the ViewController.
--Instead, make ViewController.view a dummy/blank view, and embed a scrollView inside that view. Then, embed another view (my CustomView) in the ScrollView. CustomView contains all the visible controls and text boxes and buttons. There is NO HEIGHT CONSTRAINT on CustomView.