Reusing a Storyboard Scene but missing NavigationController - ios

I have a 'details' scene that can be navigated to by a drill down search. But I also have a qr reader that when it reads a QR code, should take the user to the same details page. Now, that all works fine. My only issue, is when the I use the scanner, I am not presented with the Navigation Controller to take my self back to the scanner. I am presented with a Back button for the drill down from the table.
What is the best method for giving me a navigation controller that will pop me back to the correct original calling view?

So the answer for those wondering, is WAY similar than I thought. In my example, I simply embedded my Scan scene in a Navigation Controller.

Related

For swift iOS app dev, how do I segue to a view that takes up part of the screen only?

GroupMe is a good example. I want to implement something similar to this..
when you press the top left icon it'll bring you to the view on the left hand side, and when you click the right hand side of that view (the chats) it will bring you back
As the documentation says:
Use segues to define the flow of your app’s interface. A segue defines
a transition between two view controllers in your app’s storyboard
file. The starting point of a segue is the button, table row, or
gesture recognizer that initiates the segue. The end point of a segue
is the view controller you want to display. A segue always presents a
new view controller, but you can also use an unwind segue to dismiss a
view controller.
As said by Apple© segues are for changing View Controllers only and cannot be used to move single views. I suggest using animations to achieve the effect you are searching, however segues are definitely not what you are looking for. Maybe this question on stackoverflow.com may help you.
And please be sure to check for information by yourself first, I got this information in less than 5 minutes by searching on Google.com.
Regards -Jorge

iOS Swift App SceneKit with UINavigationController

I'm currently developing an app on iOS using mostly UIKit, it's an informations and health app, not a game. It's for a company that produces chairs, so we planned to add 3D models of each chair in a small view.
I managed to import the 3D-models as chair.dae and display them using a SCNView. The complete app is build with Storyboard and Segues, combined with a UINavigationController, so the user could get back and forth on the NavigationBar.
Now the problem is, the Navigationbar on every other ViewController is working as intended.
Only on the ViewController that has the SCNView added, there is no NavigationBar at all. I used a normal ViewController, added a SCNView and connected it to my navigation with a Show Detail Segue.
Another issue is, while most Views get pulled from the right side of the screen when i switch, this one is pulled from the bottom and replaces everything
Is there a way to force it to show a navigation bar?
I tried with following, but didn't change anything
navigationController?.navigationBar.hidden = false
That sounds like correct behavior for a Show Detail. Per Apple's View Controller Programming Guide for iOS:
This segue displays the new content using the showDetailViewController:sender: method of the target view controller. This segue is relevant only for view controllers embedded inside a UISplitViewController object. With this segue, a split view controller replaces its second child view controller (the detail controller) with the new content. Most other view controllers present the new content modally.
(emphasis added).
Why not a Show instead?

iOS navigation best practice for adding items

I cannot find the answer to this although I have implemented this rather a few times already, but maybe the wrong way.
Say I have an App for iOS, it has a main screen, which goes to a list, that list has a < back (to main) and an add button. Now when I click < back, I go back to main as that's the pop() from the stack. No issues so far.
Now when I click the add button, that is added to the stack as well; when I click back on that screen I go back to the list which is fine.
The problem is; when I save the new item, I want to go to the detail screen, but I don't actually want to have the add screen on the stack anymore while it will be there. I want the < back button for the detail item pointing to the list.
I know how to do this, but what is actually the best to implement this with the navigation stack?
Well for adding elements the best practice is to present an ModalViewController.
In this way it is not added to the stack.
Update
Let's take as examples simple apps that apple provide with iOS, Contacts app. When you want to add a new contact a VC is presented.
You'll need to implement "Done" or "Save" button that will dismiss the modalViewController and if you want to take the user into detail screen you could post a notification or other mechanism on dismissViewController method's completion block that will push the detail page from the list. But be careful on animations if you dismiss the modal VC animated and push the detail page animated you could get some unexpected behaviour. My proposal is to dismiss the Modal VC animated and push the detail page without animation.
You can override UINavigationController's viewControllers property after you pushed detail view controller. Just get current viewControllers property array, iterate and find the one you don't want to see and remove it. Remember to set viewControllers array again.
https://developer.apple.com/library/ios/documentation/Uikit/reference/UINavigationController_Class/index.html#//apple_ref/occ/instp/UINavigationController/viewControllers

iOS Storyboard Conditionally showing Views

I am currently working on a project for the iPad using Storyboards for the 1st time and I am wondering if my approach is the correct way to do this.
The first ViewController in this example is actually a split view controller.
Currently within the iPad app when a user clicks on the Export Features Button I am conditionally requesting the segue based on some code / checks I am running
[self performSegueWithIdentifier:#"subscribe" sender:self];
[self performSegueWithIdentifier:#"filterOptions" sender:self];
[self performSegueWithIdentifier:#"showExportedDoc" sender:self];
However I am not sure if I should have 3 navigation controllers and also when a user clicks on the Buy button in the subscribe View Controller it pushes to the Filter Options View which is actually nested in another Navigation Controller.
Any help / advice on this would be great as I mention I am just not sure if I am following the best approach with this.
Thanks
... and
also when a user clicks on the Buy button in the subscribe View
Controller it pushes to the Filter Options View which is actually
nested in another Navigation Controller.
Well, I think you have some misunderstanding here. The fact that the filter options view controller is embedded within a navigation controller in your storyboard doesn't mean that it will be instantiated with the UINavigationController when you're pushing it within the current navigation controller (It will be so though if you connect the segue to the UINavigationController that it's embedded into).
To answer your original question, I don't see right and wrong approach here. It all depends on the structure you would like to have. For me, I guess I would prefer to have only one UINavigationController that manages everything (set it as an initial view controller and embed your home view controller within it). This would provide a more consistent navigation experience to the user, plus more consistent look (navigation bar would be shown from the beginning).

adding a view to UISplitViewController in Storyboard, Xcode

in my application i have a UISplitView, but before this gets loaded I need to display a page where the user enters some details and then clicks okay to display the spitView. I have tried dragging a view controller from the object library on the right but this gives problems. Please advise me on the right way to approach what I'm trying to do,
Thank you
I would have the splitview present the viewController that collects the user data. Present it modally then dismiss it after they enter the data and the split view will be there for you.

Resources