Is there a better way to segue back to main menu? - swift

I need several view controllers to segue back to a main menu. After adding the terminal segues, by adding a button and creating a show segue, my storyboard looks like a rats nest of confusion. Is there a better way to link the terminal view controller back to a main menu, or is this how it's done?

After reading up, it looks like this is the best solution for my needs, since there is no data to push from the terminal view controller.
#IBAction func backToMain(sender: AnyObject) {
self.navigationController?.popToRootViewControllerAnimated(true)
}

Related

Unwind segue results in black screen? UITabBarController with embedded VCs and segues

I have the following hierarchy for my app:
UITabBarController, first tab is a BrowseVC (another UIViewController). BrowseVC has a SegmentedControl, each of which will show a version of the PersonVC (another VC with a UICollectionView in the ContentView). They are each loaded with a lazy instantiation like this article. Tapping a cell in the PersonVC will show PersonDetailsVC via a modal segue.
I'm attempting to put a "Back" button on the PersonDetailsVC to get back to the PeopleVC collection view. I thought I'd have to put the unwind segue in the UITabBarController, however, while it is called just fine (a print statement shows it "works"), the view is black.
Using the Xcode view debugger, the PeopleVC is in the hierarchy on the left, but I've no idea where it is physically.
For this configuration, which VC should the unwind be located in? I've tried putting in the BrowseVC and the PeopleVC but it would seem logical that the TabBarController would need to reload all of the content? Is there a best practice for this scenario? I can't imagine this is very unique at all. What gotcha(s) might I be missing?
TIA!
Apparently it is the modal presentation that is killing the unwind capability. Other presentation methods work fine. Disappointing.

Making Inspector Sidebar in macOS Window

I would like to make an "inspector sidebar" in a macOS window. You know the inspector in Xcode:
The sidebar's content should be context sensitive. Depending on the user's selection in the main window there should be different dialogs.
Which technologies do I have to use to get this behavior?
My attempts were (in Storyboard):
Insert a Split View into the window.
Insert a Tab View Controller into the right Custom View of the Split View
But this didn't worked: I could easily insert the Split View into the window. And I could easily insert a Tab View Controller to the Storyboard. But I was not able to insert the Tab View Controller into the right view of the Split View.
So how do I achieve the desired behavior?
Finally I solved the issue. I had to add a CustomView to each of the tab's CustomViews. This way, Xcode added ViewControllers automatically. Here are the individual steps:
First, I had to insert a SplitView into the storyboard. Nothing problematic here yet.
Second, I've added a TabView (Style: tabless) into one of the CustomViews:
And third, I needed to add ContainerViews to each of the tabs:
This way Xcode added ViewControllers for each of the tab's ContainerViews:
No I can chose the different Tabs programmatically:
#IBAction func showInspector1(_ sender: NSButton) {
self.tabView.selectTabViewItem(at: 0)
}
#IBAction func showInspector2(_ sender: NSButton) {
self.tabView.selectTabViewItem(at: 1)
}
I would like to thank for the comments, that helped me making progress and solving this issue.

i am new to ios programming. i m looking sloution for this prblem from many days.. i would be grateful if anyone help me

thanks in advance
here is the image which will help you understanding my problem
there is menu button where "Back" is written.
i want to implement slide menu on RecordsVC. tableViewController will be sliding menu, slide menu will contain EditContact, Download Records, Settings.. what should be the exact navigation flow. where should i push segue from RecordsVC... i know where to set "sw_rear" segue and "sw_front" segue from SWRevealViewController.. m just asking where to push the segue after RecordVC...
how to connect RecordVC and SWRevealViewController
update and Download are buttons which takes to addUpdateVC and DownloadVC simultaneously.
enter image description here
i hope i would be clear this time.
take a look at image what should i do
If i understand correctly you are trying to go from Menu to View Controller so you have to create a new segue from Menu View Controller (TableViewController) to View Controller whatever you want then click on segue then go to "Attributes" section set the Segue Class to "SWRevealViewControllerSeguePushController":
Then on Menu View controller call
performSegue(withIdentifier: "goToFavorites", sender: item)
If you want to go a View Controller directly from front view controller use this code:
let vc = MyViewController() // init this from storyboard
self.revealViewController().setFront(vc, animated: true)

Go back to previous storyboard

I'm currently developing a framework in Swift that includes a storyboard that I designed myself. What I need to do is that the user that uses my framework can create a segue to my storyboard. Then I'd like to be able to recreate a segue to the user storyboard that that I "leave" my storyboard.
How could I do so ?
Thx !
Your question is vague and I am not entirely sure what you are asking. However, I can't comment yet so I will try to answer with what little I know. It seems like you are asking how to transition storyboards. The simplest way is using a UIButton in your storyboard. Open up storyboard and go to the navigation controller. Then, add a button to the Nav Controller. Right click (or control click, depending on your settings), and drag the line to the main storyboard. Lastly, click on the show option. When a user clicks on the button, it will immediately switch to the main view controller. Don't forget to add the button in the view controller. Hopefully, this is what you meant and helps. If you wish switch view controllers in code, this is a duplicate and you should go here: How to switch view controllers in swift?. If this doesn't answer your question, comment and I will try and help. For future reference, please provide more information: snippets of code, pictures, anything that better demonstrates your problem.
I fixed it by getting the instance of a new view controller added on the user storyboard with the view controller identifier like so :
ProcessOut.backViewController = storyboard?.instantiateViewControllerWithIdentifier("back")
And then I present it like I would present a normal viewController from my storyboard.

Navigate through views in storyboard xcode

I'm using segue show to navigate from a view to another. I'm using
self.performSegueWithIdentifier("Nextview", sender: self)
to navigate around, but i don't quite understand this functionality. Does this make a new instance of view - if yes, does the old view get dialoged/deleted? Another thing is should i use the same method when i want to navigate back?
self.performSegueWithIdentifier("PreviousView", sender: self)
if not, what should i do to navigate back? Hope you guys can help