Definition of (the relevant part in) my app:
I have map in my view (MAP). User clicks a view, app reverse geocodes to get the address and segues to another view (PICKER), it lets user select from picker the name she wants for the place or go to another view and give custom name (CUSTOM).
Problem is that when I try to unwind from CUSTOM it fails.
In custom I unwind to the same method as from PICKER that I have in MAP's controller i.e.
#IBAction func unwindCancel(segue:UIStoryboardSegue) {
// do nothing as saving was cancelled
return
}
#IBAction func unwindSave(segue:UIStoryboardSegue) {
self.reloadGeodesics()
}
Below I present how I made in the storyboard the unwinding, i.e. ctrl drag Cancel (and Save) to exit and select corresponding Action segue.
These are my error messages
2015-11-02 14:58:59.753 via[19620:2883125]
-[via.LocationNamePickerViewController unwindSave:]: unrecognized selector sent to instance 0x7bb35770
2015-11-02 14:58:59.789 via[19620:2883125] *** Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason:
'-[via.LocationNamePickerViewController unwindSave:]: unrecognized
selector sent to instance 0x7bb35770'
when I click save. via is my app name and LocationNamePickerViewController is the controller of PICKER.
I have looked many tutorials and to me I seem to be doing everything right.
Is this a problem of doing the segue from clicking Other in PICKER to CUSTOM wrongly? Does the navigation controller between the MAP and PICKER crash the compiler? From the error it looks like PICKER's controller cannot delegate the action segue call to the MAP's controller. Can this happen and if it happens how can it be fixed? Everything works fine in the PICKER, the problem is just with unwinding the CUSTOM.
The way you create unwind segue is not right,you should create segue like this
Control + drag from Location Enter VC to Map Exit
Gif
Hope this will help you
You placed UINavigationController after Map View, so LocationNamePicker controller and Location Name Enter controller is on stack of that navigation controller, so it seems it doesn't recognize Map View Controller's unwind action even you selected that action in storyboard.
Why don't you put navigation controller before Map View Controller?
I think it will not crash then.
Related
Trying to move from my first ViewController to my second ViewController (both using same storyboard), using a segue. My first ViewController has two buttons, one that says "Male", one that says "Female" (I know, not everyone associates with one of these two), and I want either, once clicked, to move to the second ViewController. I drag/dropped the button into my code to get the following:
#IBAction func femaleButton(_ sender: AnyObject)
{
Globals.onboardingList.append("girl")
print("it's a girl!")
performSegue(withIdentifier: "femaleSegue", sender: self)
}
The Male button is identical. Using printlines I know that the program works until the "performSegue" line. I added visual segues and put their identifiers as maleSegue and femaleSegue. However, I am getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[Train.SecondVC
_setViewDelegateContentOverlayInsetsAreClean:]: unrecognized selector
sent to instance 0x7fc482d02b00'
Thanks so much for any help!
In my case I got this error because I had made a custom ViewController class and mistakenly assigned it to the View in the Storyboard instead of the ViewController. Check your Storyboard View and ViewControllers for custom classes and make sure you've set them appropriately.
I can't figure the real problem as i believe you are not using the right identifier or made the segue connection from storyboard from the wrong view controller, however to make sure, please make one segue ctr + click on the button and drag it to the second screen and comment your action, if this works then remove that segue and the previous two segues and do it again but focus this time :)
I segue from one Storyboard where the View Controller is written in Objective C to another Storyboard where the View Controllers is written in Swift 2 and it goes through fine.
However, when I click fire the next segue in the second Storyboard, I get the following error:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'record'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
This is the code that calls the next segue in Swift 2
self.performSegueWithIdentifier("record", sender: nil)
The initial view in the second Storyboard is embedded in a Navigation Controller as well.
Also worth noting, I tried without the first storyboard and my app going directly to the second storyboard, and it finds the segue fine.
Any ideas on what could be causing the problem?
Choose the segue, go to its Attributes inspector and change the Kind from push to Modal. Let the presentation and Transition remain default.
This will work fine for you.
But if you want the segue of kind 'Push' then the first View controller which is written in Objective-C should be embed in Navigation Controller.
I have a app project I am working on. I created an unwind segue in my main view as
#IBAction func unwindToHomeScreen(segue:UIStoryboardSegue) {
}
It works from another view from the cancel button
however in the same view when I call the segue
self.performSegueWithIdentifier("unwindToHomeScreen", sender: self)
The app crashes with
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<TravelSave.AddVacationTableViewController: 0x7907f380>) has no segue with identifier 'unwindToHomeScreen''
Any suggestions?
Although you say in your comment, that you've "created the segue programmatically," from the screen cap you've posted in your question, it's clear that you've appropriately linked the segue to your cancel button within the storyboard. Within your storyboard, you need to add an identifier. Select the segue within the view controller scene, then add "unwindToHomeScreen" as an identifier:
The problem I was having was when I attached my Cancel button to my exit segue I did not put the identifier on the segue shown here
I have a few views embedded in a navigation controller.
I've created a few segues (some from buttons to other view controllers, some from one view controller to another one.
for example I have a segue (Show) from one button to a view controller called name2, when I press the button it works great, but when I try to call it programmatically the app crashes and gives an error.
This is how I call the segue on ViewController1
self.performSegueWithIdentifier("name2", sender: self)
this is from ViewController1 to ViewController2
I also have a segue that is connected not to a button but from vc1 to vc2, gives the same error.
This is the strange error I get:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (ViewController2) has no segue with identifier 'name2''
I tried cleaning the product and also reseting the simulator.
A screen shot of my storyboard
A screen of the identity inspector of viewcontroller1 (it is actually called ViewController in my project)
A screen shot of the segue (name3)
The options of the segue :
Edit:
I found that when I connect a button as an IBAction and then call performSegueWithIdentifier("LogIn", sender: self) from the button it works correctly.
Any help?
Do not connect your Button in Storyboard Editor to the other segue (when you want to call the performWithSegue function within your ViewController1) - just connect the first ViewController to the second One.
Then you can use
self.performSegueWithIdentifier("name2", sender: self)
within your ViewController1 class.
When you set the Segue from one view controller to the other, ensure that you have correctly set the class - see image:
UIStoryBoardSegue was what mine needed.
The error says that you're looking for a segue in ViewController2 but your question states that the segue comes from a button. That would explain why it can't be found.
Try to remove the segue identifier ( name ), build ( cmd + b ), then set the segue identifier and compile. ( in storyboard of course )
Ok the answer is that I'm pretty dumb,
Whenever I was creating new ViewControllers, I was subclassing ViewController which was my first ViewController, instead of UIViewController which made it run recursivly.
So I have a programmatically created array of "buttons" which are actually UIImageViews. All of the buttons can create an action, or give an Alert. When this button is pushed I want it to go to a scene in my storyboard. Here is the code that I've tried out that I thought would have worked:
if (b3.alpha>0.75 && CGRectContainsPoint(b3.frame, location))
{
[self performSegueWithIdentifier:#"News" sender:self];
}
I have a segue from the menu view controller to my news view controller with my Segue Identifier as News. My problem is that if I were push to the NewsViewController's class the news display doesn't register for some reason. It seemed that if i set the news scene to the initial view controller it works perfectly, and I've put a button on the scene temporarily and pushed from button to scene and that worked perfectly as well.
I've looked around for another solution but no matter what I try it either will not go to the scene in the storyboard or i'll keep getting libc++abi.dylib: terminating with uncaught exception of type NSException.
Any help would be appreciated!