I created a menu for my app, and I have three view attached to this menu, so when I added the final 3rd view controller and created the class to control that ViewController and when I run it It won't work it shows me this error: "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'", but then I take out the class form the view controller and it just work! I have created new Cocoa Touch class and added it again but it won't work! :( here is where I add the class to the ViewController
With the other classes I have, Like the RGBViewContoller it works but only when I create a new class won't work. I have tried to unlink and link again the segue in the storyboard but it doesn't work, then I tried to do this through code and also didn't work. Heroes the code:
if blueButton.selected {
self.navigationController?.pushViewController(CMYKViewController, animated: true)
}
So my mistake (this is so everyone know in what I mess up so you don't do it again as me) was that I created a UINavigationController subclass instead of a UIViewController subclass. Hope it helps to everyone who has this problem.
Related
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 saw many questions similar to mine but no solutions worked and this may be because I am creating and then importing an iOS framework into a project.
Basically, I have a SignIn framework and I want to show a webview if the user is not signed in.
My normal project will call my framework and if I need to authenticate, the SignIn framework will tell me to load a certain .xib to sign in.
In my framework, this .xib is named SignIn.xib It contains a view controller with a webview inside as you an see:
Now, in my framework, I init the view controller and call a function of the delegate to load the signInView:
NSString* const frameworkBundleID = #"iOSLoginSDK";
NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID];
SignInViewController* signInViewController = [[SignInViewController alloc] initWithNibName:#"SignIn" bundle:bundle];
[self.delegate loadSignInView:signInViewController];
In my project, I simply do the following and this method will be called by the delagate:
-(void) loadSignInView:(CYMSignInViewController *)signInViewController {
[self presentViewController:signInViewController animated:YES completion:nil];
}
However, I have the following error when I try to run the application:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SignIn" nib but the view outlet was not set.
I am using XCode 6.3.2
Edit 1: I think the problem happens because I have a view controller inside my xib. Can I do that?
Edit 2: Here are my outlets in my .xib
Edit3: I tried to recreate the nib but I still get the same error.
Here are the steps I did:
I created an empty xib
I added a view controller and then I added my element onto it
I created a view controller file and I set it as the custom class of the view controller
Am I missing something here?
Okay, so basically, it seems like you can't have a view controller in a standalone .xib. I think because the .xib is a view controller in a way (someone could clarify).
What I did, is that I created a view, set my design properly and then, I assigned my ViewController class file to the File's owner. That way, it is now working.
I've search almost every related question, but still can not find a clue...
Here is what I did:
1.Create a scrollView using storyboard.
2.Programticaly created 10 myController(which are UITableViewControllers) inside the scrollViewController, So I can use panGesture to switch between tables. and it's working fine.
3.Created a tableViewController using storyboard, set myController to be the corresponding view controller.
4.Embedded the tableViewController in navigation controller.
5.Control drag from tableViewController to a new view controller to create a push segue.
6.Setup segue identifier in storyboard.
The Problem is:
A. When try to segue programmaticaly: use [self performSegueWithIdentifier:#"test" sender:self]; in tableView:didSelectRowAtIndexPath: method.
The exception shows all the time:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MyTableViewController: 0x8b413c0>) has no segue with identifier 'test''
B. Than I tried prepareForSegue: but it has never been called.
C. I've checked the segue identifier...there is no problem at all.
What's happening here??? Anyone has any idea???
EDIT:
ScrollViewController and TableViewController are separately created on the same storyboard. no connection/segue between them.
PIC Updated.
I'm in the "awesome" position to have to support someone else's code even though before this project I have never worked in objective C or made iOS apps, so please excuse me if I'm doing something really obvious or stupid.
I needed a new view controller with a custom class. First I drew the view on my storyboard. Then I created a new class which I derived off of UIViewController. Then, I set the view's custom class to this new class I made. I hooked up the single button on the view to the code so I could make it close the view, then I made a (manual/modal) segue so I could call this new view from my main menu. All of this should be hooked up fine because I've used it before, but I'll show you how I call the segue anyway:
[self performSegueWithIdentifier:#"ScoreCard" sender:self];
Now, my problem is that when I press the button to run the above, I get the following error:
-[Scores _setViewDelegate:]: unrecognized selector sent to instance 0x9b4c460
Scores is the name of my custom UIViewController class. Its .h file looks pretty simple for now:
#import <UIKit/UIKit.h>
#interface Scores : UIViewController
- (IBAction)goBack:(id)sender;
#end
The .m file doesn't do anything besides what Xcode put in there by default and my implementation of goBack:
- (IBAction)goBack:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
Does anyone know what I'm forgetting? I successfully added another view controller yesterday in the same way and that one works just fine. Why doesn't this one?
The error that you're getting, -[Scores _setViewDelegate:]: unrecognized selector..., seems to be caused by setting the class of a UIView to a class that's not a subclass of UIView. Make sure that you've set the class for your view controller, not the view, to your custom class.
I have a tabbar ios application. I put (embed) NavigationController in one of the viewcontroller,then added one button and one new viewcontroller to pass. I dragged from button in first vc to new vc and select "push".
But following error message is thrown when I tab the button :
Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
I really don't understand because I have already a navigation controller and also not added any additional code yet.
Thanks for any help.
You may not use push segue with a button that you have created yourself. Try using Modal segue instead.