ios7 suddenly navigation bar height change - ios

hi i want to solution in ios7's problem.
My classes is
AlphaViewController : UIViewController,
BetaViewController : UIViewController
when AlphaViewController will appear, Alpha's navigation bar hight is 44.0f.
looks like too. and Supported Orientation is Portrait.
then I use presentmodalViewController for BetaViewController.
BetaViewController's navigation bar will be hide in viewWillAppear.
and Supported Orientation is LandScape.
then I use popViewController function. so AlphaViewController will be appear again.
I use self.navigationController.navigationBarHidden = YES;
But suddenly Alpha's navigation bar hight is changed.
It looks like 22.0f. I don't know reason..
my english is not good.
thanks to read.

first of all presentModalViewController: is deprecated since ios6 so you may not use it for presenting an view controller.
When you present a viewController from an navigationController if you want the navigation bar to be present on AlphaViewController you dont need to hide or un hide. Since you are presenting the BetaViewController navigation bar will not appear and when you dismiss it will be visible again in AlphaViewController.

Related

How can I ensure iOS 13 modal view controllers present the right status bar colour?

With the new iOS 13 view controller changes, view controllers are being presented that don't cover the whole screen. They instead leave a black space at the top. However, the system status bar is not changing colour automatically. When I present a modal view controller, the status bar is staying with now-invisible black text (and a green battery which looks super weird in the middle of nowhere).
How do I make the bar behave in the same way as within Apple's apps, where the bar animates to different colour when a modal popup appears?
I've tried setting modalPresentationCapturesStatusBarAppearance to true on my modal controllers, to no luck.
The bar in my presenting view controller is a UINavigationBar, and is not part of a navigation controller. The presenting VC is its delegate, and I've overridden position(for bar: UIBarPositioning) to return .topAttached.
I've tried presenting the modal with .modalPresentationStyle = .formSheet and without setting .modalPresentationStyle at all. Neither worked.
Broken:
The presenting VC:
Expected Behaviour:
Two things:
The modal view controllers need to have VC.modalPresentationCapturesStatusBarAppearance = false. This is the default but if, like me, you set it to something else, make sure it's false!
You need to ensure that View controller-based status bar appearance in your info.plist is set to YES. I'd messed around with it in an attempt to make my status bar the right colour but having it set to NO was a problem.

Hide UINavigationBar 3D touch

I am trying to 3D peek and pop items in a UITableView. Everything works fine, except the target ViewController has a UINavigationBar which also shows.
I added my UINavigationBar to my ViewController code through Interface Builder and set self.navBar.isHidden to true which hides the UINavigationBar, but it leaves empty space equal to the size of the UINavigationBar.
Does anyone know how to hide the UINavigationBar properly?
Note: I am not using a UINavigationController, I simply added the UINavigationBar to my ViewController by drag/drop.
the target ViewController has a UINavigationBar which also shows
Use a real UINavigationController plus UITableViewController (as its root view controller). This is an excellent way to have a navigation bar even if you never intend doing any navigation.
Here's a big advantage of doing that: You don't even need to hide the navigation bar when you peek! Use the UITableViewController alone as the peek navigation controller, and the UINavigationController when you pop. Thus, the preview won't have any navigation bar but if the user presses all the way and you do the real transition, the new view controller will have the navigation bar. Remember, no law says that the peek view controller must be the same as the pop view controller!

UIImagePickerController vs status bar iOS8

I'm subclassing UIImagePickerController in attempt to override its default status bar behavior and having mixed results. My app uses view controller-based status bar appearance.
Without subclassing, I'm finding that it changes the status bar style to Default (dark) when the picker is dismissed, and nothing I've tried yet in my initial view controller is fixing it. Also, when the picker hides the status bar while being presented, sliding it upwards, the initial view controller's navigation bar slides up with it from height 64 to 44.
So I want my UIImagePickerController subclass to keep the status bar style as LightContent and, in an attempt to work-around the sliding navigation bar, keep the status bar showing while presenting the picker, then hide it on viewDidAppear:.
The first interesting thing is that preferredStatusBarStyle and prefersStatusBarHidden in my picker subclass weren't called at all until I also overrode childViewControllerForStatusBarStyle and childViewControllerForStatusBarHidden to return nil. This seems to indicate that normally, a UIImagePickerController is overriding those, probably to return an internal child view controller. Looking at the view hierarchy in viewDidAppear:, there's certainly a child PLImagePickerCameraView and its likely there's a controller to go with it. Sadly we cannot override this controller.
Overriding those childViewControllerFor... methods, preferredStatusBarStyle and prefersStatusBarHidden do get called in-between viewWillAppear: and viewDidAppear:, and can indeed keep the status bar visible and LightContent. The second interesting thing though, is that before the presentViewController animation the status bar briefly blinks dark. No amount of extra calls to setNeedsStatusBarAppearanceUpdate in viewWillAppear: or other places such as viewDidLoad: seem to prevent that.
The third interesting thing is that the bar style is still getting set to dark during dismissal, and no extra calls to setNeedsStatusBarAppearanceUpdate in the picker's viewWillDisappear: or viewDidDisappear: seem to prevent that.
tl;dr -- I've found that overriding UIImagePickerController to hide & show the status bar on demand to work pretty well, but setting the bar style is problematic. Something in the picker class or UINavigationController itself is automatically preferring the Default bar style, and when its switched to that on dismissal, it seems difficult to switch it back.
I've seen the Question UIImagePickerController breaks status bar appearance, and nothing I've seen there has helped yet, and iOS8.1 doesn't fix it. I was sure that setting the picker's navigationBar.barStyle to black would do it, but no dice. Any ideas anybody?
(Also, any tips on preventing a UINavigationController's navigation bar from sliding up to 44 height when the status bar is hidden would be useful thx)

Toolbar issues with iOS 7/8

I am having some trouble hiding toolbar (Bottom bar) on one of the view controllers in my iOS app. So I have a home view controller which has a navigation bar and a toolbar. Then a UIPageViewController is pushed (a tutorial for the app). There should be no navigation or toolbar on this screen.
I used the standard code to hide the toolbar. Here it is:
self.navigationController.toolbarHidden = YES;
It works in iOS 8 but not in iOS 7. I tried many variations and tried putting it in viewDidLayoutSubviews, viewWillAppear, viewDidappear and also right before pushing the view controller. Nothing works. Hiding navigation bar worked without issues.
Any help is much appreciated.
A better property to use when you want the toolbar hidden when pushing is setting hidesBottomBarWhenPushed to YES on the UIViewController you are pushing.

How to hide the UITabBar and show UIToolBar?

I read several answers to this question but couldn't figure out how to do it. I'm using Xcode 4.2 with ARC and no storyboards.
I'm developing an app based on the TabBar application template and extended it to contain 4 UITabBars. I'm not using UINavigationController but instead using UINavigationBar next to the status bar. When the app is loaded with the first tab shown, I have a button on the UINavigationBar and when I press it, I want to hide the UITabBar and instead show the UIToolBar at the same location where the UITabBar was located.
I tried to hide and show using the hidden property (hiding the UITabBar and showing UIToolBar). What happens is the UITabBar is hidden but the UIToolBar is shown above the location where the UITabBar was shown before. This looks ugly and I want it to be shown at the very bottom of the screen.
I think I can't use hidesBottomBarWhenPushed as I don't use a UINavigationController but instead using Navigation bar directly.
Also, I want to revert back to showing the UITabBar and hide the UIToolBar when pressing the same button on the UINavigationBar.
I am not sure if my idea would work for your scenario. Here it is...
but before, just let me tell you that hiding UITabBar, unlike hiding UINavigationBar is not animated. So to me, hiding tabBar is not a user-friendly approach, unless you create your own subclass of UITabBarController that animates hiding the UITabBar.
You can use presentModalViewController:animated and dismissModalViewControllerAnimated: methods. The viewController that is being shown modally can have a UINavigationBar, it pops out from the bottom of the screen and covers the UITabBar with animation.
Hope that helps.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

Resources