topLayoutGuide not updated after Rotation - ios7

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.

Related

Add horizontal and vertical scroll bars to NSView for MacOS app using XCode Objective-C

I am new to macOS standalone application development and I am working on fixing the issue in our existing application. I am running with an issue where the controls inside NSView are getting cut off at bottom and right side of NSView..I am using Xcode 11.3 in macOS Mojave 10.14
I would like to implement scroll bars horizontally and vertically to NSView so that i can be able to view the controls that are getting cut off at the bottom and right side of NSView. Can you please suggest on how to implement scrolling for MacOS NSView?
NSScrollView provides scroll bars.
The controls inside NSView are cut off, example:
Select the view in IB. Choose menu Editor -> Embed In -> Scroll View
If scrollbars are visible (Setting in System Prefs):
If scrollbars are invisible:
Resize the NSScrollView if needed and add constraints between the scroll view and its superview or sibling views.
Enlarge the Custom View and constrain the size of the Custom View by adding size constraints or constraints between the Custom View and its subviews.
Constrain the location of the Custom View to the topleft of its superview to remove the layout errors.
Build, run. The view is scrolled to the bottom. If you want to start scrolled to the top then create a subclass of NSView, override isFlipped and return true. Set the class of the Custom View in IB to this class.
override var isFlipped: Bool {
get {
return true
}
}

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

UIViews are displayed distorted when I set statusBar to hidden

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.

Navigation controller: in landscape mode, going "back" animation pushes down

I have a navigation controller inside a tab bar controller. When In landscape mode, the back button animation pushes down, rather than to the right.
What do I need to do to make it push right like it does in portrait mode? Thanks.
I have seen this happen before if one of your UIViewController's does not have landscape support.
Double check your shouldAutorotateToInterfaceOrientation in both of your UIViewControllers and make sure they both return YES for both portrait and landscape.

How do you rotate buttons on a ToolBar?

I have 3 views in my app. Two are in portrait, and one is in landscape. I have a toolbar at the top on the main view that displays in each subview. On the landscape view, I can rotate the tool bar to get it on the top of the "rotated" landscape view, but I can't get the buttons on the toolbar to rotate. Any ideas?