How to move table view in navigation controller - ios

I have a navigation controller and when I place an image for navigation bar by hiding it the table view which is below the navigation bar it is moving upside and first row is hide by the image. I want that (row) table to move down.
If I am not hiding the navigation bar its working correctly and the image also added above the navigation bar perfectly but I am not able to see the navigation bar back button on the next screen because whatever image I added was covering this bar.
How can I remove this image if we cannot move the tableview in first view?

if you are trying to put an image into a navbar's title, as it sounds..a much simpler way is:
UIImageView *headerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"myimage.png"]];
self.navigationItem.titleView = headerImageView;
[headerImageView release];

Related

UIView overlapping Navigation Bar

In a viewController I programmatically create a UIView that has the same height of the screen. The problem is that navigation bar is still visible and clickable, but I want it to go under the new view. How can I do that?
EDIT: this is a screenshot of what I have now
Not sure if this is what you actually want, since hiding it is a quite acceptable thing to do. However you can hide the rightButtonItem and disable the left one:
self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.backBarButtonItem.enabled = NO;
And to get back your right bar button, if you need it again somewhere:
self.navigationItem.rightBarButtonItem = self.*whatever*ButtonItem;
See if that works. I'm away from my Mac at the moment, so can't check it myself.
Right now you have taken navigation controller as a root view
controller (Maybe),In this case navigation controller overlaps the
UIVewController's view that's why it comes on the view so you need to
hide the Navigation controller.
What about making it hidden?
self.navigationController.navigationBarHidden = YES;

How to add Navigation bar to view controller with tab bar item

I have an app that uses bottom tabs aswell as a side menu, to have the button that initiates the side menu i use the typical three line menu button, to put that there I have a Navigation Bar. With the bar in place there is no way I can get the bar to be on top of the screen. I built it with interface builder, and heres a screenshot. The question is how do i have the navigation bar alone without the other grey bar above it?
The issue you're encountering is due to the fact that you're manually creating a navigation bar for your view controller, instead of using the bar that you get for free by embedding the view controller in a tab bar controller, hence the reason you see two bars. The other answer suggesting hiding the auto-generated navigation bar is not the correct solution. Instead, you should place your menu button and view title in the auto-generated bar instead of manually creating your own (you almost never want to do that, in-fact).
So what you should do instead is set the title property of your view controller to be "News", and the leftBarButtonItem property of the view controller to be your hamburger menu button (an instance of UIBarButtonItem initialized with an image for the icon).
For example (inside your view controller's viewDidLoad method or wherever appropriate):
self.title = #"News";
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"menuIcon"] style:UIBarButtonItemStylePlain target:self action:#selector(showSideMenu)];
If you want to remove the topmost navigation bar you need use self.navigationController.navigationBarHidden = YES; for view controllers that used for tabs in UITabBarController:
// StoriesViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}

alternating between toolbar / tab bar

my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo.
the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:
[self.navigationController.tabBarController.tabBar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?
That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use
self.hidesBottomBarWhenPushed = YES;
In your init method or awakeFromNib... and then
[self.navigationController setToolbarHidden:NO animated:YES];
In the viewDidLoad for example.
That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.
Try to assigning toolbar with appropriate frame and adding it to self.tabBarController.view

remove toolbar from navigation controller

I have a navigation controller where I add a toolbar based on user input.
When the user hits back to the home screen. I don't want the toolbar.
self.navigationcontroller.toolbar.hidden = YES;
This just hides the toolbar and the UIImage on the homepage is now shifted up the 40px and the black background appears where the toolbar is hidden.
How can I REMOVE the toolbar so the image doesn't get pushed up.
self.navigationController.toolbar.hidden = YES;
needed to be replaced with...
self.navigationController.toolbarHidden = YES;
To keep the position of the child VC's frame move it with 40px down (animation with duration 0.25 f.e.), when you hide the toolbar, or change the navigation controllers bounds origin with origin.y+40, just like you would do, when you are hiding the status bar. But i think an empty space will remain, you should do something with it.
For swift you need to write:
self.navigationController?.isToolbarHidden = true

Image view hide navigation bar in scroll view

In my ipad app, there is one navigation bar and one image view within scroll view.
When i run my app, the image view hide the navigation bar.
So, i remove image view and run again, then i see navigation bar.
But, i can't click the button in navigation bar.
Please, tell me how can i solve it?
Keep in mined the hierarchy of the view , if the UIScrollView is on top of the views , then any view behinde it will not receive any touch event.
The navigation bar added with XIB is a part of the subviews in you main view so you have to start the UIScrollView under the navigation bar , y = 44
ScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, self.view.frame.size.width,self.view.frame.size.height-44)];
and do not forget to subtract 44 from the ScrollView height to fit the screen.

Resources