How to anchor an UIView to the bottom of layout (with in-call status bar) - ios

Created a custom tab bar and while trying to anchor it to the bottom of my UIViewController found that the in-call status bar moves the bottom anchor weirdly.
To demonstrate my problem, I create a fresh iOS project, put an label in the Main.storyboard and constrain it to the view's bottom.
Then, when I run the project and toggle the in-call status bar, this happens (label in bottom left corner)
Searched already 2 days on the internet for an answer, but couldn't find anything which is relatable... I get it that the view gets resized, but I would still expect that my label shouldn't move. So is there a way to disable this choppy resize movement or how does the UITabBarController, with its TabBar, avoid this?

Related

Hide Bottom Bar When Pushed through Autolayout

I have a UITabBarController with one UINavigationController holding a UIViewController as root view controller.
when tapping one of the button in the UIViewController, I push a regular chat window UIViewController (with TableView + Input View) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)
In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.
The problem
when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.
For clear info check this screen shot
Now I will let you the know the constraints of the table view..
Now I am showing the constraints of the InputView
I am also adding my View hierarchy...
I had a similar issue in my project. I solved it by selecting the view I wanted anchored to the bottom (in your case, the input view), held Command, and selected its superview (both views should be highlighted now).
Then I selected the align button at the bottom of IB:
And added a Bottom Edges constraint.
What I had done initially is used the pin menu to pin the view to its superview, but it appears that will pin it to the bottom layout by default, which causes that weird movement during the transition.
EDIT:
After seeing the latest screenshot, the problem could lie in one of the superviews. I'm assuming that chatWindow is a UIView, and your Scroll View is horizontal only. Here's what your should check:
chatWindow is pinned to the scrollView's bottom similar to what I've outlined above.
scrollView is pinned to its superview as I've outlined above.
Moving the inputView outside of the scrollView to the root superview. Then one by one move it down the hierarchy towards its current location.

UIView Under Nav and Tab Bars

Using storyboard and Swift, I have a view controller which has two elements on it. A UITextField, and a UIView, which I use merely to give a colored border to the UITextField. The UITextField is a child of the UIView. See:
The problem I am having is that despite having set the top bar and bottom bar simulated metrics attributes to Opaque Navigation Bar and Opaque Tab Bar respectively, See:
When the app builds and runs the top of the UIView is always underneath the nav bar. My over all feeling is that this is somehow a constraints issue but I have not been able to find the solution to it. How do I set the constraints so that the UIView is always immediately underneath the nav bar, and the bottom of the view is always just on top of the tab bar?
Select your UIView in storyboard and assign constraints to the top margins and to bottom margins. There is a 'Pin' button you use to do this that looks something like a Tie-Fighter ship in Star Wars, it is located at the bottom right of your storyboard view.
This will set margins to stretch to top and bottom always.
That is what the layout guides are for. Pin the top to the Top Layout Guide and the bottom to the Bottom Layout Guide. The guides will always move to adjust for any top and bottom bars.

UIView bringSubviewToFront Breaks AutoLayout for UIScrollView

I have a rather simple screen where I am inserting a custom UINavigationBar at the top of the screen and a content area below it. I'm using AutoLayout and I'm visually declaring the relationship as so:
#"V:|-0-[_navBar(65)]-0-[_content]-0-|";
Now, this seems to work perfectly until I tried to have another view slide down from under the navigation bar. The nav bar contains a search field and I want the search results to slide down from under nav bar. As the code currently stands, the search results slide down on top of or in front of the nav bar and it looks quite strange. So I tried to push the nav bar to the top of the index stack using:
[self.view bringSubviewToFront:_navBar];
As far as the animation is concerned, it works perfectly. The search results no longer slide over the nav bar but they are in front of the content area. When the child of _content is a UIView it seems to be OK. However, when the child of _content is a UIScrollView, this seems to have introduced a 20px margin between the nav bar and the content area. Honestly, the space seems to be very close in size to the status bar although the nav bar has stayed the same height. I've tried bringing the nav bar to the front using many different techiniques but as soon as the nav bar and the content area are on different planes, it seems to break the autolayout constraint of 0px that is defined above.
Here is a sample project to show the bug. Look at the third item, "bringSubViewToFront bug".
Does anyone know what's going on?
The 20 point space seems like it would have something to do with the status bar, but I'm not sure why bringing the navigation bar to the front would apparently cause the scroll view to inset its content. Anyway, I was able to fix it by adding this line, after you bring the navigation bar to the front,
_scrollView.contentInset = UIEdgeInsetsMake(-20, 0, 0, 0);

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.

Any quick solution to make a view appear behind the status bar in iOS 7?

I'm porting my app from iOS 6 to IOS 7 (there will eventually be a complete GUI redesign for iOS 7 but in the meanwhile just getting the existing GUI to display properly on iOS 7 is the goal.
I had the issue where the status bar was overlapping my GUI and so have shifted the Y origin of the view controller's view down by 20.
However my app contains a pulldown which when retracted is overlapping with the status bar. In the screenshot the red is a button which is present in the pulldown view. The grey bar is the top of the main view behind which a portion of pulldown is hiding when retracted.
I implemented the pull down as a fixed size child subview of the main view and when retracted its Y origin is a negative number thus it is effectively still displayed but off the top of the screen. When the user pulls it down I just animate the increase in the Y origin until eventually the origin is 0.
Is there some way I can make the pull down view appear beneath the status bar or some other quick solution?
Note of course I can't simply toggle the pulldown's alpha to display/hide it as it pullsdown obviously thus its appearance/disappearance is not a discreen action. I could maybe attempt to make the portion of it that is on top of the status bar invisible but as its something that is moving that seems like its going to be complicated. Is there any simple solution?
Thanks
Add another view, with a fixed position, under the status bar (with the same color of your grey bar), 20px tall and same width of the status bar, but with a z-index higher than the retracting view. This view will cover the retracting view (but not the status bar) acting as a "background" for the status bar itself. Obviously you have to adjust the Y position of the retracting view to make it tappable by the user (but under the status bar)
iOS 7 by default lets views take up the fullscreen, including the status bar. This is controlled using the UIRectEdgeAll property.
If you want the old style view, set UIRectEdgeNone for self.edgesForExtendedLayout
in viewDidLoad:
self.edgesForExtendedLayout = UIRectEdgeNone;

Resources