I'm developing an iPhone app that switches from a table view to a landscape fullscreen view (similar to the YouTube app). When it does so, I want to hide the status bar, then display it again when switching back to the table view. I'm using setStatusBarHidden but that just seems to hide the status bar wihout enlarging the screen area; there's still a blank bar where the status bar was. If set the hidden status bar property in Info.plist then I get the enlarged screen area but when the status bar displays it overlays the view.
How do I hide the status bar in such a way that the full screen is available to my view when it's hidden and only the screen under the status bar when it's displayed?
TIA.
Craig
PS: I copy/edit this question from app discussion. do not find good solution
http://discussions.apple.com/thread.jspa?threadID=1580662&start=15&tstart=0
Your view controller should have wantsFullScreenLayout set to YES, as well as hiding the status bar: See UIViewController reference.
If there is anyone looking for a solution where the above solution does not work (and there is still an annoying blue 20px gap at the top), try putting this in the viewWillAppear on the implementation file of the view controller that you would like the status bar to be hidden.
self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);
That literally took me 12 hours or so to fix, and that was the solution, so now i'm spreading the word in case anyone else has this annoying issue.
Related
I have a view controller that is composed of a web view and a toolbar with some basic controls. The toolbar is pinned to the bottom of the screen using auto layout. It has four constraints, to pin it to the left side of the screen, the right side of the screen, the bottom of the screen and another that pins the bottom of the web view to the top of the toolbar.
I am having too issues with this. The first is that the web view when loading a URL has a black bar running across the bottom of the screen for a second or two while the page loads, see attached screen shot. This occurs on both iOS7 & iOS8.
[EDIT]
This bug and the one below are related I think. I just discovered that the horizontal indicator when scrolling displays not at the bottom of the screen but higher up, where it would appear if the tabbar where present.
[/EDIT]
The second issue I am having with iOS7. The screen that calls this screen is the typical navigation bar inside a tab bar setup. The user presses a button to go to a particular page, the browser gets created and pushed onto the navigation bar stack. It hides the tab bar when created. In iOS8 this works perfectly, the toolbar is pinned to the bottom of the screen. In iOS7 the tab bar is removed but the toolbar is placed as if the tab bar was still present?! Any ideas how to fix these two issues? Many thanks.
FYI - Xcode 6.1.1
The "black bar" is most likely your app window background. At the time of loading the web view is still under the navigation bar. Perhaps the constraints are being overridden. Check your storyboard settings:
If this is it, it might solve the second issue as well.
Speculation
The reason iOS 8 works is because from Apple talks I gleaned they realise many dev had issues with their views being under the nav bars by default. Introduced with iOS 7. They likely changed this in iOS 8 but found no written evidence. If someone can confirm or deny this, I'll update the answer.
This is a continuation from original problem. Part of the original problem was solved and with new understanding I wanted to be able to restate the problem that still exists, acknowledge the problem that was solved, and provide more information on it and give a better title, due to new understanding.
My app is tab bar based, and has a UITabBarController that is created through the main nib (MainWindow.xib). Each tab references a UINavigationController, again created through the main nib (MainWindow.xib), and each UINavigationController has a root view controller created in the nib as well. Each of these UIViewControllers is a custom VC that has its own nib, class definition, etc.
The application is set (in the app plist) to have a translucent status bar. This works. The status bar is translucent. The first 4 tabs all have a custom background image (currently 2 images composited on the fly with the second being an overlay with < 1 alpha -- will eventually be replaced with a single composited image once development is done) in their individual VC and the last uses a standard background color chosen in its individual nib.
The translucent status bar should overlay the background image, as each image is currently set full size and upper left origin (320w x 480h -- will eventually be replaced with one that cuts out the tab bar at the bottom for efficiency and origin 0,0). However, this only happens in the first tab, and in the tab that uses a nib set background color/pattern.
Beyond the initial setting of the rootViewController in the app delegate did finish launch method,
[[self window] setRootViewController:[self tabBarController]];
there is no layout code in any of the VC. It is all defined in the nibs. (Yes I am old school)
Here are the two that work:
On the first image you can see that the "white" outline of the background image continues up along the sides and across the top of the status bar. On the second one you can see the background stripes continue up into the status bar.
Here is one of the three tabs that this does not work right on:
You can see that it does not have the white going up into the status bar and across the top. Instead of translucent black on blue it is just black.
Here are the shots from IB to show that they are all set up exactly the same
The root tab bar controller:
First Tab Navigation Controller and viewcontroller (which works correctly):
Second Tab Navigation Controller and viewcontroller (which does not work correctly):
I have been researching this and trying different things for a few days now and don't know what to try further. Everything appears to be set up identically and there is no layout or view altering code in the view controllers viewDidLoad or viewWillAppear: methods.
If there is anything obviously wrong (or not so obvious) I would appreciate a pointer. As far as I can tell it should work
I have an app where i have set the status bar to be hidden, in the plist.
At first all looks fine, but then in one place in my app i use presentModalViewController to show another view. (this view is to show the twitter login screen)
When i get out of the view (twitter login screen) and i get back in my app all my views move up.
After reading a lot i know its because all the views think that the status bar is hidden and we should move up 20 pixels, but i have already accounted for the status bar being hidden and i dont want the views to move up.
Is there any way i can fix this?
I'd like to add a custom UIToolbar to my UIViewController. In Interface Builder I add the uitoolbar at the top of my view, and it looks just fine. However, when I run the app in the Simulator it gets hidden by the default iphone bar (this one with the clock, battery status, etc.).
Here you can see how it looks like:
example http://www.cs.put.poznan.pl/jjurkiewicz/private/uitoolbar_hidden.png
Any ideas?
Seems like you're adding your view at coordinates (0,0), the top left of the screen. The view is then getting drawn behind the status bar. Make sure to add the view in the right position, to place it below the status bar it should be at (0,20)
You shouldn't hide the status bar needlessly - so use the IB inspector on the window/view, and under "Simulated Interface Elements", set status bar to anything bar "None". This should be how a new view is created in IB.
You can always just hide your status bar with the "Status bar is initially hidden" property in your Info.plist
I am looking at example provided by Apple called LocateMe. I am basing my application on similar UI flow. In that example the top bar of the screen is black. Looking in the code and xib file I am not able to figure out how did they get that black bar on the top. When I set up my project exactly like them, I get blue bar. Please help.
That particular project did it by setting UIStatusBarStyle to UIStatusBarStyleOpaqueBlack in their Info.plist (which is why you couldn't find it). You can also achieve this in code this way:
[[NSApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
EDIT: I re-read your question, and it's not clear whether you're asking about the navigation controller bar or the status bar (which is the bar at the very top of the screen). The above is for the status bar. The Navigation Controller bar was set to black by going to the GetLocationSetupView.xib and selecting the Navigation Bar and selecting the "Black Opaque" style.