How do I segue from uiviewcontroller to TabBarController - swift

performSegue(withIdentifier: "m1", sender: self)
The code above is correct here below but it's giving me a SIGBRT (*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'm1'') error claiming the receiver login has no segue with identifier 'm1''
even the login is segued correctly to the UITabBarController with the correct identifier. Forgive me, i'm a beginner developer.
enter image description here

The call to perform the segue must be in the initial view controller, not the destination view controller. In this case, self.performSegue(withIdentifier:"m1", sender:self) should be in the UIViewController, and NOT the UITabBarController.

Related

I can't Segue using a UIButton from UIViewController to UITableViewController

I'm getting Thread 1 SIGABRT in my AppDelegate class with the following
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController
loadView] instantiated view controller with identifier
"UIViewController-ynt-fo-t3z" from storyboard "Main", but didn't get a
UITableView.'
Storyboard arrangement:
UIViewController --> UITableViewController
I'm using a menu Button item from UIViewcontroller to trigger the segue. I have tried everything including preparedforSegue method. The only way around is to change the target view controller back to UIViewController while implementing UITableViewDelegate and UITableViewDataSource which I'm not too fond of using. Any solutions to my madness?
I had a similar issue long time ago; I tried anything, and nothing worked. I ended up using a new UITableViewController and segueing to it; And the issue was resolved. (it seemed like a bug in Xcode or something)
Do the same and see if it works for you.

What is this error in swift: "signal SIGABRT"

I've tried all the solution, though I think it's related to segue.
this is the message for the error:
UserLoginAndRegistration[34910:1717023] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'LoginView''
The error message has no segue with identifier 'LoginView' is pretty clear.
Make sure that
A segue is designed in Interface Builder for the Receiver controller and
LoginView is written into the Identifier field of the segue.

Swift app crashes when popToRootViewController called - Exc Bad Access

My Swift app crashes when I have about 4 view controllers on my navigation stack and then at the 4th I call popToRootViewController. It pops, so I know the UINavigationController exists, but the app crashes without any error other than Exc Bad Access. It also crashes when I dismiss the UINavigationController instead of popping to root view controller.
Note: This happens only when running app on my test device. When my it's ran while my test device is connected to Xcode, it never crashes.
This is the only code in my final view controller, other than viewDidLoad of course.
Code:
#IBAction func closeBtnPressed(sender: AnyObject) {
//dismissViewControllerAnimated(true, completion: nil)
self.navigationController?.popToRootViewControllerAnimated(true)
}
Any ideas? Thanks!

performSegueWithIdentifier not working properly with swift

I am currently trying to segue to a different view controller when a button is pressed. The button's action method is called correctly, but when it calls the perform segue with identifier it crashes the app and says "terminating with uncaught exception of type NSException". I have the segue identifier as "switchToMap". I segue to the same page from a different place in the app as well, but that seems to work just fine. Does anyone have any ideas?
func mapButtonPressed (sender: UIButton) {
performSegueWithIdentifier("switchToMap", sender: sender)
}
The other place the map page is segued to looks like this. It is part of a switch statement.
case 2:
performSegueWithIdentifier("map", sender: indexPath.item)

Modal segue not working from code

I've already spent the whole day in an issue and did not find a solution yet. I have a UITabBarViewController and I am trying to fire off a modal segue from one of its tabs. I've already created the view I want to segue to, created the segue itself (from the tab's view controller to the target's view controller) and the identifier. In order to test my segue I created a UIButton in my tab and wrote the following code on its action:
[self performSegueWithIdentifier:#"showProductInfo" sender:self];
The modal segue worked fine. But if I try to write the same code to be performed somewhere else (inside a specific method that is called after I receive a web service response) the segue simply does not work. I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'showProductInfo''
This is driving me crazy! Any help is more then welcome.
Editting:
Some additional findings:
If I take off the performSegue from the method I am currently using (which by the way is called by DidFinishLoading) and put it on ViewDidLoad the segue is performed successfully.
Thinking that it could be a thread related issue I included the performSegue inside a dispatch_async(dispatch_get_main_queue()... But the error is the same !
If your destination viewcontroller is inside a navigationcontroller, then take a look at this question:
http://stackoverflow.com/questions/8041237/how-to-set-the-delegate-with-a-storyboard
Furthermore, from the error it looks like the segue you are trying to perform is not attached
to the viewcontroller you are starting from. So,Try to remove the seque and drag it from the
viewcontroller.
The current view controller must have been loaded from a storyboard. If its storyboard property is nil, perhaps because you allocated and initialized the view controller yourself, this method throws an exception.
Make sure you have Storyboard ID for your destination VC (in this example myViewController).
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"myStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *myViewController = [storyboard instantiateViewControllerWithIdentifier:#"MyController"];
[self.navigationController pushViewController:myViewController animated:YES];