Can't add navigation bar to scene: Root view controller issue? - ios

I'm still struggling with navigation bars and just can't work out how to edit or verify that I have a navigation bar on my view and I would appreciate any help.
I have a project with another set of scenes similarly comprising of a navigation controller and three associated view controllers (connected via segues and main table view embedded in the navigation controller) and I was able to add a navigation bar manually in interface builder to the outer view controllers that were segued to the table view controller.
But in this set of scenes the navigation controller is set up as the root view controller for the table view.
I have another set of scenes. A navigation controller and two related view controllers - both table view controllers. I embedded the first table view controller in the navigation controller and I then added a second table view controller to this (for a new screen I want to add to my app) and I connected this second table view controller to my first table view controller by way of a show segue (just like I did yesterday with other set of scenes).
Can I set this other navigation controller as the root controller also?
Like, can I have two root view controllers in a project?
It looks to me like there is a navigation bar visible (see screenshot below) on my new table view controller but I can't click in to it to edit it to add a title to it.
But does a navigation bar and exist, and if so, why can't I click inside it and use it?
I was told in an answer to a previous question that you have to add a navigation bar manually to your storyboard scene to any additional view controllers. I did that yday and it worked. But today when I tried to add a navigation bar by dragging onto scene it wouldn't let me do this.
Here is the screenshot:

Try adding push segue(which is depreciated) and than change it to a show segue(between your tableviews). This is a workaround I use in my apps.

Ran into the same problem. Had a good fallback position, I am doing a tutorial that came with example programs completed and working so the first thing I did was see if it was a version glitch between 6.3.2 and 6.4. Turned out the earlier project worked just fine.
So what I did was simply drag the 'Item' in the sidebar and moved it under the Root View Controller!

I've experienced the same issue.
However, by saving and closing the project then reopening it, the Navigation Bar title is then able to be edited. Prior to closing/reopening the project the field could not be edited.

Related

Back Navigation from Embedded UISplitViewController Using Single Navigation Bar

I’d like to have split views in several places of my iOS app, none of them as the root view controller. I understand that split views are initially designed to sit at the root of the app and provide the root navigation controller, and that Apple’s guidelines initially did not allow any workarounds. Updated guidelines state
You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases.
Now the split view pattern would really benefit my app, and I don’t want to reinvent the wheel here, so I gave it a try using a container view, mainly using the following steps:
Create a scene with a regular UIViewController.
Add a UIContainerView covering the entire screen.
Add a UISplitViewController to the storyboard, which creates a split view controller, a navigation controller, a table view controller (for the master view), and a regular view controller (for the detail view).
Create an embed segue from the container view to the split view controller.
This has a few quirks, which I hope to iron out eventually (e.g. initially showing detail view, swiping in the table view from the left on an iPad apparently tries to also back nav on the main navigation), but it basically works. So far, so good.
Now, the problem is that I have two navigation controllers: the main navigation controller at the root of my app and the navigation controller in the embedded split view. This gives me two navigation bars with independent navigation, allowing me to:
navigate back to the root of the split view using the embedded navigation controller
navigate back from the container view in the enclosing navigation controller
Besides two navigation bars not being appealing, I don’t want iPhone users to perform the second directly from the detail view. So my next steps were:
hide the navigation bar in the outer view controller
add a back navigation button to the inner navigation bar to take over the role of the main navigation bar’s back button
Left to do is the implementation for that back button that pops the container's view controller of the main navigation stack. The question is: how can I access the main navigation controller from the embedded view that has its own navigation controller (using Swift)?
Accessing the navigation stack of the parent's (containing view controller's) navigation controller turned out to be straightforward:
#IBAction func backButtonTapped(_ sender: UIBarButtonItem) {
parent?.navigationController?.popViewController(animated: true)
}
I had to face a similar kind of problem while developing my app.
My problem was, I had to display navigation controller and splitviewcontroller on side bar. Again a problem was navigation controller form splitview to navigation controller. Below are the steps which i followed
1) While creating a split view controller, I hided the navigation controller of master and detail and set it to root view, please also keep the reference of your top level navigation controller.
2) I increased the 'y' of splitview.root.window and view to accommodate custom view.
3) I created a custom view with a back button and then handled the transition with animation.
Please let me know if you want code snippets. I would have shared it now. But i have to search for it.

iOS Swift How to go back from a split view to a normall view controller

I have a simple iOS app that I want to use a split view in, but I also need some normal view controllers(non Split view). So I have my story board setup like this:
Story board
I will add more views to the base navigation view depending on what they click on in the first view some will go to other standard views and one will go to another split view. as I can not add the split view to my base navigation view (get an error saying it had to be the root view) I replace the root view with the split when the button is clicked using a replace Segue.
My question is: how do I get back to the first view once I am in the splitview? can I somehow had a custom back button to the detail view title bar to go back? Or am I going about the whole thing wrong? Any help or a push in the right direction would be great!
I ran into this problem myself. Unfortunately, UISplitViewController cannot be added as a child of another view controller. I must be the root view controller of a window. From the docs: When building your app’s user interface, the split view controller is typically the root view controller of your app’s window. The way I got around this was just creating a container view controller in my storyboard: It ended up looking like this:
It's pretty basic, just adding the two view controllers as children of the parent view controller. You can control the width of each on straight in IB.

using my ViewController as a TabBarController

So i currently have a ViewController that has a tableView in it with a tab bar on the bottom. Its basically an instagram clone. However, i built all the tableView functionality and am now just getting around to playing with the tab bar items to segue to new view controllers.
I cant figure out how to attach my already created tab bar(which is inside a regular view controller) to other view controllers in IB.
The ctrl+drag from the newly created view controllers to my MAIN view controller doesn't work. It doesn't provide an option to create a view controller segue.
Below is an image of my current view controller and a brand new one to the right
Any help on how i can do this would be greatly appreciated
On you tabbbar controller ctrl+click and drag to the view controller you want to create a relationship to.
Then when the little menu appears, under 'relationship segue' click 'view controllers'
You should then end up with something like this. Continue the same process to add more relationships.

SWRevealViewController hierarchy leading to black screen

Firstly, I would like to say that there are no errors with my code from a programming standpoint - it runs successfully, so a round of applause for that. However, the issue I am having is that when I run the application, it displays a black screen. I assume the issue has something to do with how I have set up the segues or something similar.
Hierarchy:
Reveal View Controller -> Table View
-> Navigation Controller -> Tab View Controller -> FirstViewController
Important To Note:
Reveal View Controller class is set to "SWRevealViewController"
Table View Controller class is not set.
Table View Controller segue ID set to 'sw_rear'
Navigation Controller class is not set <possibly the issue, but I cannot set the class to SWViewController as suggested by a thread online.>
Navigation Controller segue ID set to 'sw_front'
All other controllers have no set class.
I have discovered the solution. Hopefully others can learn from this.
When you create a project using a Tab Bar Controller as your base, an arrow will appear to the left of the Tab Bar Controller in the Storyboard. Moving that arrow to the Reveal View Controller (View Controller you set to the class of SWRevealViewController) lets Xcode know that you want to start your hierarchy from that object.
I had the same problem. What helped me resolving the issue was to remove the Navigation Controller that linked to the view (in my case was UItableViewController), and re-insert a new Navigation Controller (clicking the tableviewcontroller, Editor > Embed In > Navigation Controller).

Using UITableViewController in a navigation bar

I'm new to iOS, but I know the basis. I want to host 3 UITableViewController in a UITabBarController using the storyboard.
I dragged a UITableViewController from the object list(?) and control dragged creating a seguel. Now the tab shows successfully the table view controller.
The issue is the rows are taking the space of the status bar. So I want a navigation bar(?) there, with a title. Since I'm new to iOS I don't know the following:
Given the fact that UITabBarController is the first controller ever, the hosted UITableViewController should not have a back button, obviously. So is it correct to use a navigation bar to display a title (and possible add/edit buttons)
If so, I tried dragging the Navigation Bar but it doesn't work.
What am I missing or doing wrong?
hope this helps
actually it is done for another answer. but it will be handy to u too
You will want to add in 3 UINavigationControllers. Have each tab in the tab bar controller segue to a different navigation controller. Then set the root view controller for each navigation controller to one of the table view controllers.

Resources