Custom navigation bar in every view - ios

I have two views, in the first i display the log in page which has a uiimage and i hide made the navigation bar translucent and in the second i have a collection view but when i scroll the navigation bar is still translucent so... i want it to be solid in the second view.
i put in the viewdidload from the second view this:
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
but when i go to the second view the uiimage of the first view is late to disappear.
what ca i do?

on the first view
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.translucent = YES;
}
on the second view
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.translucent = NO;
}

Related

uinaviationcontroller pop animation become weird when status bar was hidden

as picture : when the white controller in popping out with a interactive pop gesture , the red controller (which make the status bar hide) will show, and during the animation : the navigation bar seems to move up , and the controller's view is still in its position (not move up with navigation bar) ,so the view seems divided into two pieces in the pop out animation . how to fix it ?
In the first controller,add this code.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

ViewWillApear only works once for displaying navigationBar

I'm navigating from a UITableView to a normal ViewController.
I'm displaying the navigationBar like this:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
The first time I hit a row in the UITableView, the navigationBar shows up, but the second time it remains hidden. This is not expected behavior, since viewWillAppear should work every time the view shows up.
Why is the navigationBar hidden when viewing the view for the second time?
This is because you are hiding navigation bar in viewWillAppear of table view. So it will hidden for other pushed view controllers. So in order to get rid of that you have to un hide navigation bar in view did disappear of table view.So it will work in desired manner.
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
}

From second view under navigation bar

i'm implementing a project with XCODE 5 and storyboard. I have added a view that is a UIPageViewController and when i alloc the first page (for this pageviewcontroller) the view appears normally but from second page the view appears under the navigation bar. What is the matter?
If i set this property
self.navigationController.navigationBar.translucent = NO;
for the view displayed the problem is solved but when i go back from Page View Controller to previous View, the buttons on it are shifted down.
Why? What is the solution?
Furthermore if i set translucent = NO the views displayed in storyboard are different from views displayed in my app (the views are not shifted in storyboard).
I can't post images because i'm not authorized.
This is the code of my PageViewController
- (void)viewDidLoad
{
[super viewDidLoad];
variabiliGlobali = [foaGlobalVariable sharedInstance];
variabiliGlobali.giornataCalID = 1;
numeroGiornate = [variabiliGlobali.calendario count];
self.dataSource = self;
foaGiornataViewController *initialView = [[foaGiornataViewController alloc] init];
// Do any additional setup after loading the view.
[self setViewControllers:[NSArray arrayWithObject:initialView]
direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];
}
The foaGiornataViewController is a view that doesn't exist on storyboard but is only a objective-c class.
Thanks in advances.
I have solved. I have setted opaque navigation bar for my Navigation Controller on storyboard.

iOS 7 detail layout when master has navigation bar prompt

I run into a layout problem in iOS 7:
To reproduce create a simple master-detail-app and insert this line in MasterViewController.m :
self.navigationItem.prompt = #"Master";
and this in DetailViewController.m :
self.edgesForExtendedLayout = UIRectEdgeNone;
Both lines in viewDidLoad.
The detail view's frame does not update correctly when the navigation bar shrinks to its normal size.
How should I fix this?
My current solution to this is to remove the prompt in the master view's viewWillDisappear:
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationItem.prompt = nil;
}
Then just set it again in the viewWillAppear. There should be a better method, however.

Alter view when detail view pushed iOS

I have a view with a custom bar at the bottom of the screen. When a collection view cell is pressed, it loads a detail view, and I can go back.
This all works great; however, I have a plus button displayed on the custom bar, and I would like for the plus button to disappear only when the detail view shows up, and then come back when you hit the back button.
So far I have used the delegate method:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// Your code to update the parent view
}
The problem is this fires when the detail view is loaded and popped as well. Any idea on how to accomplish this? Thanks!
I assume mainView and detailView are viewControllers. In mainView's viewWillAppear method
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//get reference of plus button here
btnPlus.hidden = NO;
}
In detailView's viewWillAppear method
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//get reference of plus button here
btnPlus.hidden = YES;
}

Resources