iOS7 how to completely hide status bar throughout app? - ios7

I'm building a sprite kit game, and normally status bar does not show within my app. However, the drag and drop code that I'm using is doing something with the window and when the item is being dragged, the status bar flickers on and off. So my question is:
How can I completely and utterly tell iOS7 to hide status bar everywhere within my app?
I tried plugging per controller code, but cannot seem to find which particular controller is showing the status bar.
- (BOOL)prefersStatusBarHidden
{
return YES;
}
I have status bar set to initially hidden in plist:
I tried using setStatusBarHidden within appDidFinishLaunching
Maybe there's some centralized setting I can set to off?

The setStatusBarHidden setting and the "Status bar is initially hidden" Info.plist setting do not work unless you also set the "View controller-based status bar appearance" Info.plist key (UIViewControllerBasedStatusBarAppearance) to "NO".
In other words, either you're doing this at the level of every single top-level view controller or you're doing it at the global UIApplication level, and this key determines which it is.
However, it is better to learn to do it the view controller way, because Apple might eventually take away the option to do it at the global UIApplication level.

Related

Can't seem to set the color or remove status bar in UIDocumentInteractionController

I'm trying to use UIDocumentInteractionController to show a PDF with a TOS and Privacy policy in my app. I either want to change the color of the status bar to match my nav bar color or I want to remove the status bar. I'm able to remove it but it leaves the 20pt spacing for it still. I'm thinking I'm unable to make this work because UIDocumentInteractionController inherits from NSObject not UIViewController, and loads some second UIViewController which one can't get access to. Ideas? Here's a screenshot:
Check this documentation
In short: if you return your navigation controller in that method the preview should respect the navigation/status bar style you are creating

iOS7 : how to set navigationItem property of UISearchDisplayController?

I have a UISearchDisplayController that works perfectly in one of my iOS6 app. Now, I want to migrate this app to iOS7.
I had read the Apple docs, and it says the following :
Starting in iOS 7.0, you can use a search display
controller with a navigation bar (an instance of
the UINavigationBar class) by configuring the
search display controller’s displaysSearchBarInNavigationBar
and navigationItem properties.
displaysSearchBarInNavigationBar is pretty easy to set up. But the only clue I have for navigationItem is the following :
Important: The system raises an exception if you
attempt to set the titleView property for a search
display controller’s navigation item.
I can't seem to find example of how to set the navigationItem. How to I say to my navigationBar to embed my searchBar? Somebody can show me an example?
Thank you in advance!
UISearchDisplayController creates and manages the navigation item needed to display the search bar in the navigation bar. You don't need to create your own, although you can access it via searchDisplayController.navigationItem after displaysSearchBarInNavigationBar has been set to YES (the navigationItem is created lazily)
When the view controller with the search display controller is asked for its navigationItem, the search display controller will return its item (which contains the search bar) instead of the view controller's.

add a subview to a not-showed uiview

I'm dealing with a weird problem: I've got a UIViewController to handle a list of items to download via inapp purchase.
When a user choses the product to buy, all the purchase flow begins. At this particular moment, I push a UILabel and a progress bar to display the current state of the download.
If, before that, a user choses to go in another part of the application (i.e. by tapping an item form the tab bar menu ), the application continues the purchasing process from there (that is reduced down to saying yes to a couple of dialog boxes and inputing the itunes store account credentials).
The process (that is attached to a background thread) runs smoothly till the end of it, but if the user comes back to the store view the UILabel and the progress bar are not show, I mean, they are initialized and running but they're not visible.
Is there a right way to behave in that circumstance?
Do I have to force the refresh of the view, or do I have to remove'em from the superView and push'em back again?
thank in advance,
hope I'd be clear enough, otherwise don't be afraid to ask, I'll be glad to
explain myself in a more deep and clear way.
-k-
Without a code it is difficult to give you the exact solution.
A possibility is that when you moved out from the original UIViewController the system did unload the view on that controller. It is possible that with this unload the progress bar and label were not destroyed (because over-retained by your view controller or not nil-ed in the viewDidUnload method) but when you entered in the view controller again the view was reloaded from scratch (typically from the nib) with new progress and labels.
So it is correct that you retained the progress bar and label (even if there are better ways to achieve the same result) but you must add them to the view controller view in the viewDidLoad method. A typical way to do this is to store a "active" progress bar in a dictionary and when the view is reloaded from the nib it must be added to it. As soon as the download finish you can remove the progress from both the dictionary and the view. There are other ways to accomplish the same result, so my suggestion is just to give you an idea.
So in order to see if my answer is correct, you must check the viewDidUnload method, add a breakpoint on it and see, once it has been triggered and when you come back to your original view, if the progress bar has disappeared or not.
Hello Holographix u havnt posted any code so it would be difficult to tell
well it seems like the object of Uilabel and progress bar are getting released the time u comes back to the view.

Reference to source view controller and destination view controller at the same time

I have a series of UIViewControllers throughout my application. Most of them have the navigation bar but some of them hide it.
The problem is that sometimes as you transition between a view with or without navbars to another view with or without navbars there is a black box that replaces the navbar during the transition. This problem was discussed here: Hiding a UINavigationController's UIToolbar during viewWillDisappear:
This solution is fine and it does get rid of the black box, but I really don't want what was described as a "Cheshire Cat" disappearance. I've tried myriad solutions using prepareForSegue, ViewWillAppear, viewWillDisappear, etc. The best I can do is change the scenario in which the black bar shows up.
By this I mean, there are four combinations of view transitions between the two navigation bar states (hidden vs. not-hidden):
Hidden - Hidden
Hidden - Not Hidden
Not Hidden - Hidden
Not Hidden - Not Hidden
No matter what solution I've tried, at least one of those combinations results in my black box rearing its ugly head. The problem I have is that I've been unable to find anywhere that I can get a reference to the source view controller and the destination view controller when popping a view off of the navigation controller's view stack.
If I could get both references in the same event, I could simply determine what the combination is and handle the behavior appropriately like I would in prepare for segue.
Now, I know that "it's not possible" is a reasonable (and even a probable) answer, but I won't accept that as a solution alone. If it is indeed not possible, I'd like thoughts on a reasonable alternative. For example, I could handle all view controller popping manually (including the default back button) and thus could get the "upcoming controller" from the navigation controller's stack.
I would just prefer a solution using built in APIs or at least a solution where my controllers didn't have to be aware of their own navigation bar states.
Thanks a lot,
Patrick
I think UINavigationControllerDelegate is what you're after. It declares two methods:
-navigationController:willShowViewController:animated:
-navigationController:didShowViewController:animated:
All you need to do is set yourself as the delegate of the parent navigation controller and implement these methods to be notified of incoming view controllers.
Having said that, I've never needed to resort to this for hiding and showing navigation bars. Strictly speaking, view controllers where the navigation bar will always be visible never touch the navigation bar's visibility. When I'm moving into a view controller where it needs to hide, that view controller is responsible for hiding and setting it back to its prior state before disappearing. Following these standards has proven reliable for me.

Prevent UINavigationController's navigation bar to animate?

My UINavigationController's navigation bar is kind of static. This means, there is no back button, because going back in the stack is done via the first entry of the UITableView the controller holds. The title also always shows the name of the root item.
To achieve this I have added my own custom view to UINavigationController.NavigationItem.titleView
It looks a bit odd if a new controller is pushed in: the old navigation item vanishes, just to get replaced by one looking exactly the same.
Is there a way to prevent this behavior? I want the animation for the content of the controller, so pushing the new controller without animation is not an option.
Add your own UINavigationBar and implement your own delegate and custom animations for the content views.
It sounds like you'll only need one UINavigationItem, so that makes this model easy to manage.