UINavigationItem Prompt Issue

I'm having a problem with an invitation to UINavigationItem, which I just can't solve ...

I have a master and detailed controller. When I click from the wizard to the part, a prompt appears on the detail view controller:

prompt

However, when I return to the main view controller, the view does not change and the window shows (the window is colored red):

window

This only happens in iOS7, on iOS6 the view changes as expected.

I tried several things, such as setting the invitation to zero in viewWillDisappear or viewDidDisappear , but nothing fixes it.

If I set the navigation bar in the navigation controller translucent, this will fix it - unfortunately, this is not an option.

I created a very small example project here that demonstrates the problem: https://github.com/InsertWittyName/NavigationItemPrompt

Thanks in advance for your help!

+7
ios ios7 prompt uinavigationitem
source share
5 answers

The solution I can think of is to subclass the UIView wizard and implement viewDidMoveToSuperview to set the view frame from the height of the navigation bar to the end of the supervisor. Since the navigation bar is not translucent, your task is simpler, since you do not need to take into account the guidelines for placing and pasting content.

A few comments. When pressed and popped, the system moves your view of the controller controller to another supervisor for animation, and then returns it to the hierarchy of the private representation of the navigation manager. Also, when the view goes beyond the view hierarchy, the supervisor becomes nil .

Here is an example implementation:

 @interface LNView : UIView @end @implementation LNView - (void)viewDidMoveToSuperview { [super viewDidMoveToSuperview]; if(self.superview != nil) { CGRect rect = self.superview.bounds; rect.origin.y += 44; rect.size.height -= 44; [self setFrame:rect]; } } @end 

This is not an ideal implementation, because it uses a fixed value for the height of the navigation bar, does not take into account the possible toolbar, etc. But you can add all this as properties to this view in viewDidLoad , before it starts to go into the hierarchy of views, sets the parameters according to your needs.

+3
source share

You can remove the invitation when the user closes the back button, for example

 override func willMove(toParentViewController parent: UIViewController?) { super.willMove(toParentViewController: parent) if parent == nil { navigationItem.prompt = nil } } 
+1
source share

You yourself answered - brilliantly. This is a mistake, but a transparency check avoids the error. Therefore, the solution should check the transparency, and then compensate so that the navigation bar looks the way you want.

To do this, make a small image of the black rectangle and include it in your project. Set the background image of the navigation bar to this image. Check transparency. The problem is solved! The navigation bar is now black opaque in appearance, but it no longer detects an error.

enter image description here

0
source share

Quick version:

 class PromptViewSideEffect: UIView { override func didMoveToSuperview() { super.didMoveToSuperview() if let superview: UIView = self.superview { let rect: CGRect = superview.bounds rect.origin.y += 44 rect.size.height -= 44 self.frame = rect } } } 
0
source share

The problem is that your navigation bars are opaque or translucent. It sucks that Apple has allowed this disgusting mistake to intimidate us for more than three years.

All of these solutions are hacks. My solution is either A) NEVER use hints, or B) use them in each individual view, even if you must set them to "".

0
source share

All Articles