UIViews are displayed distorted when I set statusBar to hidden - objective-c

I have a bunch of UIViews that are displayed on a viewController. They are setup before I call presentModalViewController. The problem is that these views are displayed distorted, specifically they have an extra height of 20, which is the length of the status bar. The problem goes away if I have the statusBar shown or I have the UIViews setup after the viewController is shown, but I need the UIViews to be setup before the viewController is shown and I dont want the statusBar to be shown when my app
is running. How do I fix this?

You can try setting the Autoresize subviews property of the viewController's view to NO.

Related

Animate view and set button backgroundimage conflict

I am making a type of drawer animation for iOS where a button tap in one of my views will expand that view over the other views from the bottom up. All is well, except when I want to change the button image after animation. The animation completes but then returns the view to its original position when setting the button image.
Things I have tried:
Using CGAffineTransformMakeTranslation instead of setCenter; this works perfectly, except I want to also add a panGestureRecognizer to interact with the drawer, present, and dismiss it. The transform doesn't seem to play well with this interaction
Adding the buttons programmatically thinking maybe AutoLayout is fussing with this
UIView beginAnimations as well as UIView animateWithDuration and completion block
Setting breakpoints and verifying that the movement of the view is reflected in the frame of the button before the image is changed; button frame is not still in original position, but has supposedly relocated with the view
It shouldn't matter, but my project is using TabBarController. I made a simpler version of what I'm trying to do with just the one view controller and had the same issue. The green view extends beyond the frame of the view controller's view so that when it moves up it reveals what is off-screen.
example: http://i.imgur.com/tRou0Js.png?1

UINavigationViewController changes the behaviour of scroll view in iOS7

I have a 'UIScrollView' that is supposed to display a list of images one next to the other. This is the code I'm using to add each image:
#define SCROLL_PADDING 10
#define SCROLL_DIMENSIONS 50
view.frame = CGRectMake(xValue, SCROLL_PADDING, SCROLL_DIMENSIONS, SCROLL_DIMENSIONS);
[scroller addSubview:view];
However, as shown in the image below, the images are loaded with a vertical offset. After some research I realised that this offset is the same as the height of the navigation bar's height.
Note 1: By default the images cannot be seen. I had to scroll up to make them visible.
Note 2: I shouldn't be able to scroll because the images should fit in the scroll view.
I decided to present the view controller modally instead of pushing it to the hierarchy of the navigation view controller and everything work as expected.
This problem only happens in iOS7. Any ideas why?
I came across this article, which clearly explains various changes in status bars and navigation bars on iOS7
As you can see in both of the images above, the position of the scroll view doesn't change. In iOS6 if the subview's frame doesn't change, it would be moved down to prevent it from underlapping the navigation bar. Since iOS7 it is expected that all subviews will underlap not only the navigation bar but also the status bar, which makes the location (0, 0) the top left of the SCREEN.
For some reason that I don't understand yet (it would be nice if somebody could explain), only the scroll view's subviews where moved down in the same way it was being done in iOS6. Hence making the subviews appear out of the scroll view's bounds.
To prevent the subviews from underlapping the navigation bar it is necessary to set edgesForExtendedLayour to UIRectEdgeNone as early as possible in the life cycle of the view controller
viewController.edgesForExtendedLayout = UIRectEdgeNone;

topLayoutGuide not updated after Rotation

I have a viewController (mainView) that supports every orientation on iPhone.
From this view, another viewController is presented with modal style, which only supports only Portrait orientation (and forces the orientation accordingly).
Usually, the topLayoutGuide is at y=20px and the layout of the toolbar right below is attached to that topLayoutGuide
Now i have the following sequence of events
display mainView in portrait orientation
open modal view in portrait orientation
turn to landscape orientation (modal view obviously stays in portrait orientation)
dismiss modal view and return to mainView
After this, the topLayoutGuide is suddenly at y=0px and therefore, the toolbar is positioned over the statusbar, and also keeps that value after rotation in the mainView.
Does anyone know how to update (or force) the topLayoutGuide back to 20px?
You can either adjust insets manually, or you can force the SDK to force to "refresh the orientation" of your controller.

Create space between navigationbar and searchBar because of UI design

I have an app where the navigationBar is implemented according to Apple HIG, so 44px high. Thereunder is a searchBar which is directly under the navigationBar.
The guy designing my app now has created an custom image for the navigationBar which is 64 px high. I already cut the image so that the actual height of the navbar image is 44 px. And added the rest of the image to the tableView background image. Everything is implemented and works correctly except that now my searchBar is scrolling through my navigationBar IMAGE. So technically it is not in the navBar but from a UI design standpoint it is.
I cannot seem to find out how to make sure the space directly under the navigationBar (20px) is not used. It should look as if the navigationBar is 20px bigger to the user.
Hopefully someone can guide me in the right direction, thanks!
I think you have your search bar nested in a UITableView right? You can change your view controller to a subclass of UIViewController instead of a UITableViewController, and then you will be able to add the table view to the controller's view manually and adjust its size whatever way you want.
(Don't forget to let your controller implement data source and delegate protocols and hook it up with your table view.)

Make detail side of splitViewController scrollable?

I am trying to imbed a scrollView in the detail side of a splitViewController. Should the scrollView be added inside the 'View', as displayed in the image below?
Or does the 'View' need to be removed, leaving a View Controller and a Scroll View only?
Also, when I add the scrollView to the page, the bottom is being cut off, preventing it from scrolling all the way to the bottom. I also tried resizing the scrollView in the ViewDidLoad method of the View Controller to something extremely large such as:
theScrollView.contentSize = CGSizeMake(20000, 20000);
That did not work either. It seems that we can hold down the mouse and pan, but the scroll bars are always the same length. Thanks your help!
I have ALWAYS implemented scrollviews as the UIScrollView with a UIView inside of it, then your other elements (i.e. buttons, text views, etc...) SO the hierarchy would be
UIScrollView
UIView
UILabel
UIButton
.
.
.
Because you dont really have a top UIView WITHIN the scrollview, this is most likely why your
theScrollView.contentSize = CGSizeMake(20000, 20000);
line is not working as intended.