iOS - Adding view under navigation bar - ios

I can't add a view under UINavigationBar (Navigation Controller), like the Facebook app. Any ideas on how I can do this?
Best,
Andrea

The custom view looks like a tableHeaderView. Which means you need to set your view as the tableHeaderView, which will then be placed on top of the tableView and underneath your navigation bar.
UIView *customView = [[UIView alloc] initWithFrame:yourFrame];
self.tableView.tableHeaderView = customView;

Related

iOS:How to add a view on searchBar in UISearchDisplayController and I want the view on top of _UISearchDisplayControllerDimmingView

How to add a view on searchBar in UISearchDisplayController and I want the view on top of _UISearchDisplayControllerDimmingView?
I add the view by [self.searchDisplayController.searchBar insertSubview:view3 atIndex:0];. But it was under _UISearchDisplayControllerDimmingView.
I show U the pic:
If someway to dismiss the _UISearchDisplayControllerDimmingView will help me also!
If you really want it on the top of dimView put your view on the window of Application.
UIView *view = [[[UIApplication sharedApplication]windows]objectAtIndex:0];
and add your view as subview.

CollectionView content goes under NavigationBar

I added a UICollectionViewController using IB. Then I added a UINavigationBar in code:
UINavigationBar *navBar = [[UINavigationBar alloc] init];
[navBar setFrame:CGRectMake(0, 20, self.view.frame.size.width, 44)];
[navBar setDelegate:self];
[self.view addSubview:navBar];
All works fine except the fact that the collection view content is hidden by the navigation bar. It doesn't only scroll beneath the navigation bar but in fact displays beneath it when first loaded.
How can I fix that?
Why are you using a standalone navigation bar? It's probably a bad idea. Embed your view controller in a UINavigationController, and make sure the top contraint of your UICollectionView is set to the top layout guide and not the view.
try changing your content offset of the collection view. I'd try either 44 (height of nav bar) or 64 (height of nav bar + status bar)
Your problem is adding UINavigationBar on self.view which is UICollectionView.
You may use simple UIViewController with UICollectionView as subview of its view. Then after adding UINavigationBar you have to change collectionView.frame.

ios - UIView to cover full screen, to cover the tabs from a UITabBarController

I have a UITabBarController and I want to add a UIView as a subview but I want that view to cover the whole screen including the tabs on the bottom. All attempts I have done result in the view cover everything except the tabs on the bottom.
Not sure what you have tried but, if you are trying to add the view from a UIViewController that is inside the UITabBarController then you should use:
UIView *coverView = [[UIView alloc] initWithFrame:CGRectMake(0,
0,
self.tabBarController.view.frame.size.width,
self.tabBarController.view.frame.size.height)];
[self.tabBarController.view addSubview:coverView];
//and maybe [self.tabBarController.view bringSubviewToFront:coverView];

UIView appearing before navigation transition is over

I'm writing an iPhone app with a table inside a navigation controller. When the user clicks one of the cells in the main screen a UIView on top of the incoming view controller is created (it's like a toolbar).
self.toolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
toolbar.backgroundColor = [UIColor colorWithRed:0.8823 green:0.8823 blue:0.8823 alpha:1.0];
[self.navigationController.view addSubview:toolbar];
The problem is that the view appears before the transition to the new view controller is complete and the effect is pretty weird. I suppose this is due to the fact I add the view to the navigationController,but I need to do this otherwise the bar would scroll together with the table and instead I want it to be fixed.
Any suggestion?
I've found a possible solution: add the toolbar as TableHeaderView and follow iOS: Add UIView to UITableView
Any other better solution is more than welcome

How to add navigation bar in uitableview

App based on Navigation base application.How to add Navigation bar in UItableview controller. Symptoms as a tableview controller(xib). I need to add in Navigation bar to symptoms.
you dont add a navigationController to a tableViewController. its the other way around.
First add anavigationController and set its rootViewController as the tableViewControler.
U can add it as you add the sub view to super view
-loadview:
navBar2=[[UINavigationBar alloc]init];
[navBar2 sizeToFit];
[self.view addSubview:navBar2];
//add button on the bar.
[navBar2 addSubview:button];
maybe u can change in the xib, add a UIView below the TableView and then add the navigation bar as a subview of UIView

Resources