I had created a xcode project of single view application. I put a tableview and navigation item on my storyboard screen. Now, I bind the array data source to tableview and set the code as below to show edit button on the navigation button.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
However, it seems can't working. I can't find any button on my navigation bar.
Someone can tell me how to make the edit button show?
Thanks!
I put a tableview and navigation item on my storyboard screen.
It sounds like maybe that's the problem. The way to set this up is to start with a UINavigationController as your storyboard's initial controller, and put the UITableViewController in a relation segue from that (as the navigation controller's root view controller). Now if the table view controller says
self.navigationItem.leftBarButtonItem = self.editButtonItem;
the edit button will appear in the navigation bar.
To see an example, start with the Master-Detail template (for iPhone). The Master view controller is structured in the way I'm describing.
Related
I've got an initial view controller InitialViewController with a button "List" (and a few other random buttons).
Clicking on "List" segues to a UITableViewController that is embedded in a navigation controller. And that is all sweet.
But once the UITableViewController is loaded there is no "back" button to navigate back to InitialViewController.
I was just wondering what my options were. On the storyboard I've used a "Navigation Item" and "Button Bar" and i'll hook that up programmatically to navigate back.
I just wasn't sure if an unwind segue was an option or if anyone had better ideas.
Thanks.
The reason you don't see a back button when your UITableViewController is loaded is because it is the root view controller for the navigation controller that it is embedded in. As such, the NavigationController has no other view controller in the stack that it can go back to.
Instead of the TableViewController, embed your InitialViewController inside a NavigationController and that should add a navigation bar with Back button to your TableViewController.
If you don't want to show the Navigation Bar in your InitialViewController, you can hide it using the following steps:
In your storyboard file, select the InitalViewController
Open the Attributes inspector and set Top Bar to None
Hope this helps!
I have a little problem related to implementing a tabbar with navigationcontrollers, when I have two views before the tabbarcontroller, which also uses a navigationcontroller.
This is my setup in StoryBoard
http://i.stack.imgur.com/8P4Zw.png
http://i.stack.imgur.com/ei3xa.png
But this is not working as I want, because I get two navigationbars (Picture number 2) when I enter the tabbar screen. I know I just can delete the navigation controllers in the tabbar or change the segue to modal, but if I do so, I would not have the ability to add individuel UIBarbuttons to each tabbar view or set individuel navigationbar titles. I would also like to use the push segue through out the app, as it is a kind of an "step by step" app. My question is: How I can eliminate the double navigationbar, when I enter the tabbar, but still have the ability to set a title for each view related to the tab and continue to use the push segue and a navigationcontroller?
I hope you understand my question.
You -can- set individual buttons for each view controller. Grab a tab bar item and drag it to the navigation bar of whichever view controller you want. You can also set the individual title of each view controller. Like you said, there is no reason for the 2nd and 3rd navigation controller you added right after the tab bar controller.
You can set buttons both in the Storyboard and programmatically and they can be different at different stages of your view controller. You should thus delete the second and third navigation controllers and either drag and drop the buttons you want where you need them, and/or deal with it programmatically if necessary.
One example of what you could do programmatically:
UIBarButtonItem *yourButton = [[UIBarButtonItem alloc] initWithTitle:#"yourTitle" style:UIBarButtonItemStylePlain target:self action:#selector(yourSelector)];
self.navigationItem.leftBarButtonItem = buttonSegueBackToAccueil;
This creates a UIBarButtonItem for the controller you are in and places it as the left button of the navigation controller bar. It will run the method "yourSelector" when clicked.
In a UITableView, I'm trying to add a navigation bar (with title and back button, to be precise). I've already embedded this view in a Navigation Controller, and in all of my other views this just worked out of the box but I can't seem to get the bar to show. I have checked the `Shows Navigation Bar' tick in the navigation controller attributes section in the IB.
What am I doing wrong here? What can I do to get my UINavigationItem to show up?
EDIT: Because some answers in other questions suggested doing this: I've already given it a title which I can also retrieve through NSLog.
Is your parent view controller in a navigation controller ? I would suggest put your parent viewcontroller in navigation controller, do what ever action you to do show UItableViewController and push it on navigationcontroller stack. You will have your UItableView in naviagtioncontroller and there will be back button to parent controller.
I'm trying to add a view that is a form that has 3 elements. These elements will be inside of a static grouped table. I need a navigation bar at the top with a "Save" and "Cancel" button. Both buttons should send the user back to their previous screen when tapped.
Within the storyboard, I have tried creating a Navigation Controller and then adding a table to it, but I get the error of "Static table view are only valid when embedded in UITableViewController".
So, I tried creating a Table View Controller, but the storyboard won't let me put a navigation bar into one of those for some reason...
What is the best way to go about doing this?
Add UITableViewController to your storyboard and then choose Editor > Embed in > Navigation Bar Controller from the menu. This will wrap your table view controller in a nav bar controller and you can then add your Save and Cancel buttons to the navigation bar.
It might seem a bit wasteful to create a navigation controller with only a single sub-controller just to get a navigation bar but it's the accepted way of doing it.
Oh... this iOS stuff is hurting my head.
I wanted to do the same thing, have a TableView, with a Navigation Bar at the top, but there was no "Embed in.. Navigation Bar" menu item, just "Embed in.. Navigation Controller".
Eventually, solving this was easier than I thought.
I just needed to add a Table View Controller to my storyboard, then CTRL+drag a Segue from the "calling" view controller to my new Table View Controller, and, voila, it gives me the Navigation Bar straightaway.
I am making an iPad app, and am wondering it is possible to get the pop down menu from a UINavigationBar without having to go through the trouble of a split view controller. Is this possible? Tell me if I'm not being specific enough.
Yes, you can do that without much trouble, but you just have to write the code. Just display a UIPopoverController from that UIBarButtonItem on your navBar.
The steps:
Create a UIViewController which manages a table view (or whatever else you want) as your menu view controller.
Add a UIBarButtonItem to your nav bar or toolbar.
Create an IBAction to called something like touchedMenuButton.
Connect that action to that UIBarButtonItem.
In that method, alloc/init that view controller.
alloc/init a UIPopoverController with that view controller.
present that popover from the UIBarButton item
Success!