UIScroll View on IOS 7 lingo - ios

okay, my app was built on for iOS 6 until iOS 7 got released and i started making changes to support both versions. Now, i'm having problems with UScrollView and it's constraints on storyboard. when i add a scroll view to my view which has a navigation bar and add a button (or any subview) for say 20 points under the navigation bar, at runtime the subview get's misplaced vertically. it moves downwards in like 60 points. i guess the same size as the navi bar and the status bar combined. So, i was pulling my hair to know how to fix it with constraints and auto layout but i couldn't figure out how. the app sometimes crashes with a certain mix of layouts. However, what i did was to pull the scroll view aside and place the subviews as i want them to look like with navi bar there, then i pulled it back in it's right place (covering the entire view) and when i run the app it all works as expected. now the question what constraints should i add so that it works as expected without doing the whole process aside and then adding it? right now my view looks like this:
As you can see the button is under the navi bar. but when i runt he app it gets under the bar as i want it to. so how can i just add it on story board under the bar and let it stay there? in iOS 6 i used to do it that way without worrying and ios 7 seems like doing this hard on us.

Related

iPhone X - Hidden status bar pushes Navigation Bar upwards

I'm testing iPhone X behavior using the Xcode simulator. For some odd reason, if I'm hiding the Status Bar the Navigation Bar pushed upwards causing the title to completely disappear and cutting the left and right buttons. This is happening only on the iPhone X.
Illustration:
How can I hide the status bar and keep the Navigation Bar at a visible position?
UPDATE:
Sample project for your convince:
https://drive.google.com/file/d/0B5qJARV-Oc9ra1hvZkpXZm9lRUE/view?usp=sharing
One solution is to embed the navigation controller inside a container view controller which is properly constrained to the safe area.
Just create another view controller and drag a "Container View" from the Object Library. This view has top, bottom, leading, and trailing constraints to the safe area, all with constants equal to 0. If you control-drag from the container view to the navigation controller, you'll get an option to set an "embed segue" which will embed the selected view controller as a child view controller.
I set the status bar to be hidden on the new view controller I created, and it works fine.
This feels like something that UINavigationBar should handle automatically, but this workaround seems like it should work pretty well.
Another note: if you change the color of the navigation bar, you'll also need to create another view above the container view, and change its color to match the color of the navigation bar.
I, for a small app, changed from using a Push to a Modal segue and adding in my own navigation bar. I used Push because it looks good, and already had a Modal for another part, which I wanted to animate differently for style reasons.
For smaller apps this may be the quickest and easiest solution, but my next update I need to use the navigation controller. For that I think I'll switch on the status bar, which is no big deal for me and allows it to work.
I think you need to use "safeAreaLayoutGuide" new update in iOS 11
Apple has provided us with the necessary APIs to get around the unsafe regions of this iphone x. We do this by using the new safeAreaLayoutGuide anchors in our code
safeAreaLayoutGuide

Xcode uiscrollview shows up behind nav bar in IB

Trying to set up a scrollview in a UIViewController that has a nav bar. In IB my content gets pushed up to the top below the nav bar (see image).
When running the app on my phone the view is pushed down to sit below the nav bar which is fine. Is there anyway to get it to reflect like this in IB. It is hard to set up my content when half of it is cut off.
If I add a constraint to make the top of the view sit below the nav bar when I run the app it adds that offset and doesn't look correct. (I guess I could alter the constraint before running on my phone but seems like a ridiculous hack just to layout my app). (Already having major issues getting my scrollView to work the way I want it to... don't scroll if my content fits the screen but also use the scroll view to move the view up if the content is covered up by the keyboard but thats for another post)
when I run in simulator looks like this
In Interface Builder you should make sure your NavigationBar is set to Opaque in the simulated metrics. When you have a transparent Nav bar content can go underneath it.
It might look right in your app if you have a global attribute applied to make sure all nav bars are not translucent.

UITextView disappears from ViewController

I have the strangest thing happening. My Text Views and Image Views randomly become invisible on my View Controller.
I am developing using Xcode 6 on OSX 10.9
I have a View Controller that is wrapped in navigation controller.
In the middle of the View Controller I have Text View. When I add an Image View or move controls somehow the Text View disappears. It doesn't re-appear at run time. There doesn't seem to be overlap as far as I can find. On the left hand side the navigation shows that the text view is there and I can select it and edit properties.
Has anyone seen anything like this?
I recommend upgrading to Xcode 6, and using its new view debugging feature to locate your view. The issue could be with incorrect Auto Layout constraints, or some views overlapping one another, etc.

How to build full-screen scrollview and hide nav bar without moving anything

If you look at a photo fullscreen in the iOS 7 photos app, the nav bar and toolbar fade away but the underlying scrollview isn't scaled or shifted. I've been trying to recreate the effect in Interface Builder using autolayout but every time I hide the nav bar it pulls the scrollview up.
What I start with:
What happens:
What I want to happen:
Has anyone implemented this before? It seems like no combination of autolayout constraints, scrollview insets, and automaticallyadjustscrollviewinsets is giving me what i want.

UISearchDisplayController on iOS7

I'm having a very annoing problem on iOS7. I have a VC with different subviews, one is a tableview that is display fullscreen after pressing a button. This tableview has a search bar with a scope bar in its header that is linked to a search display controller.
On iOS 6 everything runs fine, when I press on the search bar the scope bar is displayed and the rows correctly slide at the bottom as you can see in the images (forget about the big X).
On iOS7 I have a problem.
Everything seems OK(and it's under the status but I know how to fix that).
But when I start a search the layout change leaving some blank space at the top, this doesn't happen on iOS6.
How can I solve that? where this problem comes from?
Andrea
It looks like your search results are pushed down by the status bar height. Try fixing your header position (so it's not under the status bar) and see if that works. If not, you'll need to share some code to show how your layouts are constructed.

Resources