Unwind Segue Navigation Bar Button Xcode 8.0 Swift 3.0 - swift

I want to create an app in Xcode 8.0 that lets the user press a bar button item in the navigation bar. Once this button has been clicked an unwind segue will take place whilst also printing, "helloWorld" to the output section at the bottom of Xcode. I have successfully created an unwind segue using:
#IBAction func unwindToViewController (sender: UIStoryboardSegue){
}
I then linked this to the bar button item on the navigation bar so that when I tap the bar button item on the navigation bar the view disappears downwards.
I am trying to simply print("helloWorld") onto the output section at the bottom of Xcode when I press the done button but nothing appears on the output section. So far I have:
#IBAction func add(_ sender: AnyObject) {
print("helloWorld")
}
in the View Controller Swift File for that View Controller.

For unwind We need to remember only two points
1) We need to put below method into Destination ViewController.It is a place where we want to navigate to. Here method name can be different but arguments matter a lot.
#IBAction func unwindToDestinationViewController (sender: UIStoryboardSegue){
}
2) Go to the Source viewController from where you want to go back. Now click on unWind button on top right and Control-Click and set outlet to the Back button(Example)

Kindly check this post on stack overflow. This is a duplicate of below post.
You can find the answer in the given below link.
https://stackoverflow.com/a/39916477/2894335
This Blog gives a very nice introduction to unwind segues. article link here.

Try the following tutorial will fix your problem and help you to understand more about how to perform unwind segue...
https://www.andrewcbancroft.com/2015/12/18/working-with-unwind-segues-programmatically-in-swift/#identifier
http://ashishkakkad.com/tag/uistoryboardsegue/
Hope this helps...

Related

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.

Button ignores action when segued to a previous viewcontroller

So here is my current issue.
I want to unwind to a previous viewcontroller lets call it viewcontroller1.
This works fine, except that the button action
that is hooked up with the segue, also has a lot of other code written in it. However, when pressing the button xcode ignores the code thats already written.
So this is my question how do I make the button perform the written code and then engage the segue??
For the unwind segue I've created an empty action in ViewController1.
#IBAction func unwindtoViewcontroller1(segue: UIStoryboardSegue){}
And hooked ViewController2 up with this segue action (using ViewController2:s exit button).
Ive also set the segue to "revealviewcontrollerpushviewcontroller"
Thanks in advance for all the help I can get I am really stuck.
Best regards Albin
You should be able to do it this way:
Open Assistant Editor, then control drag from the button that performs the unwind segue in ViewController 2 to create an IBAction. That's where all the code for the action you would like your button to do should go.
This action gets performed before the unwind segue function is called.
So your button will do both: action and unwind.
I have made a simple project to illustrate and printed the output to the console. The button in yellowVC performs an action before unwind.
So as you said, in the first ViewController (in my example the green one you have an IBAction for unwind segue
#IBAction func goBackToGreenVC(segue: UIStoryboardSegue) {
print("go back")
}
Then in the second ViewController (in my case the yellow one), control drag from the button to Exit to set unwind segue and then also control drag from the button to Assistant Editor for an IBAction, something like:
#IBAction func goBackToGreenVCButtonTapped(_ sender: UIButton) {
print("performing an action before unwind")
}

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)

swift Xcode 6 unwind segue action doesn't fire

"Done" button of the modally presented controller ("Modal") is bound to an exit action defined in the primary controller ("Main"):
#IBAction func done(segue:UIStoryboardSegue) {}
"Done" button is not firing!
I have tried the manual segue approach from Unwind Segue in Xcode 6 Beta 4 and bound the "Done" button action to following code in "Modal":
#IBAction func donePressed(sender: AnyObject) {
performSegueWithIdentifier("unwind", sender: self)
}
it doesn't work too!
if I remove tab bar controller everything is working fine - is that a bug or a restriction?
P.S.There is an annoying log output I can't get rid of:
2014-08-17 16:14:15.380 SwiftPhotoCards[9113:497540] 17545849:_UIScreenEdgePanRecognizerEdgeSettings.edgeRegionSize=13.000000
no idea whether it is related to the issue or not but I thought it's worth mentioning it.
I've been struggling with what may be the same issue (although I'm using a Split View instead of a Tab Bar) and was able to resolve it by setting the Modal segue to "Presentation: Current Context" instead of "Default" in the Attributes Inspector:
(This is the setting on the Segue arrow that creates "Main" to "Navigation Controller" in your screenshot).

How to return from "partial curl" type segue

I am attempting to use a partial curl segue to reveal an options view underneath my main view. This is identical to touching the "page curl" button in the bottom right corner of the Maps app.
I can successfully execute the segue to the option view, my problem is returning to the main view. I'm hoping to replicate the reverse animation effect of the Maps app as the edge curls back flat and the main view is shown.
It doesn't seem logical to create another segue to return back to the main view (what I would do if I were not using the partial curl segue) because the return segue is associated with the original segue.
Thanks in advance for any help!
try
-(IBAction) buttonPressed{
[self dismissModalViewControllerAnimated:YES];
}
This should work!
Or i believe you can press the back side of the turned page and it will return automatically with out adding any code! Hope that helps!
In Swift dismissModalViewControllerAnimated has been renamed:
#IBAction func handleAddButton(_ sender: Any) {
self.dismiss(animated:true, completion: {})
}