scroll views working fine in iOS 7 with problems in iOS6 - ios

I hate iOS scroll views with auto layout, they are driving me crazy!:-D
I have found a method which works perfectly on iOS 7 to use scroll views:
I put the scroll view directly in the main view, attaching the scroll view to the edges of the super view(top,bottom leading and trailing space equals to 0).
Then I put a UIView into the scroll view attached to the edges of the scroll view, (top,bottom leading and trailing space equals to 0).
Then I set the height constraint of the most internal view, I link it at my ViewController class, and I modify its value programmatically.
Or, if the view it's 'static' I put every component using the storyboard into the internal UIView, starting with the one at the Top attached to the top of the super view, the one under, attached with the constraint 'Vertical Spacing' referred to the one over him..and so on... Until the last, which is also attached to the bottom of the UIView..
Everything works fine in iOS 7, it's perfect, but iOS 6 is messing around with the constraint.
When I first launch the view everything is perfect, but it seems to recalculate the constraints even on the didappear(and in a bad way), in fact, if I leave my view while it's scrolled down, when I come back to it(let's say we are in a navigation controller) , is like it's everything 'moved up' and the components at the top are hidden.
Is there a way to make scroll views work in both iOS 6 and iOS 7, I'n thinking at two storyboards as the only solution, please tell me there is another way... :-)
thanks everyone, I post two images explaining my problem, taken from the top of the screen:

Well uncheck use AutoLayout in file inspector and try.

Related

UIViews inside a super or master UIView, display correctly in StoryBoard but shrink in the emulator

I am quite new in swift programming and I am developing an app which has multiple custom views, hope some one can help me here.
The issue is that I have a scrollView, inside I have a stackView with about 20 Views inside, every view has inferred constraints and every view has a fixed height, maybe not the best practice but most of the views show correctly (had to re-do about 3 times to get here), but one of my views (around the middle of the stack) is showing correctly in my story board, but somehow it's shrinking it's subviews when launching the app, not sure if I am missing something, I have even removed all the content of these subviews and left only the main views with their heights but still I have the same issue.
To be more detailed the section that fails is a view inside the vertical stackView, it contains a view (container) which has the same leading, trailing, top and bottom as the first one. This container view, contains 5 (sub)views which have the same height each (124), and have practically the same content: a label, a texfield and a custom slider (thought the slider was ruining everything because it's custom but after removing all from the design the error still occurs).
Here is an image of how it's shown in the story board:
views in story board
And here is how it's displayed in the emulator:
view in emulator
Does anybody now why can this be happening? I am not doing any layout stuff in the code only a couple of corner rounding in other views that are inside the stack view.
BTW, I also implemented this 5 slider views using a vertical stack and had the same issue, I switched and changed to simple views and separated by 10 each bottom with the next view top.
Thanks

iOS - Top Layout Guide height issues

I am refactoring some views in my application regarding iPhone X constraints and moved a group of views into a TabBarController view with also a Navigation views. Everything working just fine but one thing. Well... There is always that "one issue left" thing, isn't?
So the issue that I have is that the Top Layout Guide is set high. And I don't want that. See screenshot about this issue.
I have set the top constraint of the labels "Maandag" and "Op afspraak" (top one) to 0. Well to the Top Layout Guide. All views that I converted to this TabBar view has this issue :( I am using Storyboards.
This is the result on device (same on all kind of devices)
Thanks in advance!
With iOS 11, Apple is deprecating top(bottom)LayoutGuide and switching to the safeAreaLayoutGuide. In code, you could pin your view using view.safeAreaLayoutGuide.topAnchor, but in storyboards you'll want to pin stuff to the safe area node inside your view controller's view:

Interface Builder is not letting me delete a button

To clarify: I have a view/vc which is designed as an orphaned scene in IB in the storyboard it is used within. This view has a button with an image, a height and width constraint, a left and top constraint. There is a table below it with top, left, bottom, right constraints set to 0. A seperate VC loads this view, sets its width to half the screen and animates it coming in and sets its delegate.
All's honky dory. Now, we wanted to edit the sizing of the button and some miscellaneous things. I noticed the constraints seemed to not be getting applied in simulator. I then, after a while of playing with constraints and losing my mind, decided that maybe something more fundamentally wrong was occurring so i decided to delete the button and see where the table below it is getting placed with it's constraints set.
Then, nothing. The button is still there. I have looked to see if I accidentally c/ped it, and I have not. Is this a known bug?
Clean the project and delete the app on simulator.

UIScrollView in NavigationController ignores top layout guide

I've seen similar questions about custom transitions(iOS7 Custom ViewController transition and Top Layout Guide and Navigation controller top layout guide not honored with custom transition), but I have problem even with regular push. I'm using latest Xcode available now (Version 5.1.1 (5B1008)).
Here is my storyboard:
Problem occurs in 3rd VC
Here is 3rd VC settings:
My 3rd controller's layout is follows:
UIView
UIScrollView
InnerUIView
Other views
I've tried two different ways to create a layout:
Ignore top layout guide (it has y = 64 because of nav bar)
I pinned scrollview's top to container (ignoring topLayoutGuide), manually set height of inner view and pinned its top to scrollView. It gave me the following result:
Looks fine, but why do I need top layout guide then?
Use topLayout guide
ScrollView's top is pinned to topLayoutGuide.
As you can see, top button moved down and view looks strange.
What is the right way of creating such layouts?
I had the same problem and spent hours pulling my hair out.
My container view inside scrollview had weird top offset despite the fact that it had top constraint set.
The workaround I've found - you have to uncheck Adjust Scroll View Insets in your controller layout options
that way content view (in my case) stays pinned to scrollview's top.
Unfortunately I couldn't find any reasonable explanation of this behaviour.
In my case, Xcode 7 and 8, I had to uncheck the 'Adjust Scroll View Insets' for the Views in my Navigation View Controller. And yes, it wasted too much time before I figured this out.
EDIT: Apple has found out that we have found a solution, so they managed to break this again in XCode 9 and 10, to keep us developers pulling our hair. Haven't found a solution yet.

Using UIScrollview in iphone5 compatible app

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.

Resources