|
|
unrecognized selector sent to instance ...
|
|
|
|
Fresh-Faced Recruit
Join Date: Jun 2008
Status:
Offline
|
|
Hi everybody
I'm a newbee in iPhone programming and I'm currently trying to develop a Snake-like to get used to the iPhone SDK. Unfortunatly I have an error I can't solve. I created a view with a button on it and wanted this button to switch the menu view to the game view. Unfortunatly I have this error :
Code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType buttonClicked:]: unrecognized selector sent to instance 0x44e1e0'
I do not understand because I have the following line in my code :
Code:
@interface SnakeMenuController : UIViewController {
}
- (IBAction)buttonClicked:(id)sender;
@end
and :
Code:
@implementation SnakeMenuController
...
- (IBAction)buttonClicked:(id)sender {
NSLog(@"Start button pressed");
}
...
To conclude, I'd like to inform you I used (or maybe tried to use) Interface Builder to connect my action with the TouchUpInside Event of my button.
Thanks a lot for your help.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Are you sure you've actually got a SnakeMenuController that's receiving the message, rather than something else?
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jun 2008
Status:
Offline
|
|
In my .xib file, I defined the SnakeMenuController as Fil's Owner and then I connected the buttonClicked: method to the Touch Up Inside Event of my button (which is inserted on the View). Reading the error message I tought my mistake was I called buttonClicked under the wrong object so I decided to connect my action manually but the result was exactly the same. I really do not understand why I have this problem because I checked with example given by Apple
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: May 2007
Status:
Offline
|
|
could you connection be backwards? make sure you connect from the button to the controller when you set up your buttonClicked binding.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jun 2008
Status:
Offline
|
|
make sure you connect from the button to the controller when you set up your buttonClicked binding.
No I started from the Controller. I thought it was possible in Interface Builder to connect action from the destination to the source. Are you telling me I have to start from the button event and then connect the blue line in my File's Owner?
PS : I'm sorry if my english is not perfect or if you don't understand everything I'm writing. Do not hesitate to tell me if you don't understand my posts. I'm french and if you ask my I can try to reformulate my sentences
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally Posted by orlin61
No I started from the Controller. I thought it was possible in Interface Builder to connect action from the destination to the source. Are you telling me I have to start from the button event and then connect the blue line in my File's Owner?
I don't do iPhone development, but source->destination is the only way to do it in the normal Interface Builder.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jun 2008
Status:
Offline
|
|
I just tried to delete the previous connection and create another one starting from the source ('Touch Up Inside' event of my button) to the destination (my File's Owner which is my SnakeMenuController) and there is no change : I still have this error "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType buttonClicked:]: unrecognized selector sent to instance 0x44e1e0'"
I don't know how Interface Builder works but do you think it is possible it is trying to connect my event to the buttonClicked: action from an object which type is different from SnakeMenuController.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2009
Status:
Offline
|
|
I know this thread is a little old, but i am having the same problem and cannot figure it out. Any resolution?
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2009
Status:
Offline
|
|
I had the same problem that was described in this thread. After quite some time I noticed, that in the inspector (right most tab "identity") for my ViewController the class was still set to "UIViewController" instead of the ViewController that contained the IBAction method. So, it's not only setting the File's owner in your nib window to your ViewController class, but also you need to set the class of the ViewController to your particular one, not the UIViewController. Look for the ViewController in your MainWindow.xib, select it, open the inspector and change class in the identity tab.
HTH,
YenZi
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jun 2009
Status:
Offline
|
|
I'd like to make note of another situation where this problem can occur:
When using Interface Builder, if you have setup a Navigation Controller and if the View Controller that is nested in the nav controller is in a different XIB file, you will need to make sure to set the Class for the View Controller where it shows up nested in your Navigation Controller AND on the File Owner in the other XIB. If you don't have the class specified in both places, you will get the unrecognized selector error.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: London, UK
Status:
Offline
|
|
This thread helped me out hugely when using a UITabBarController with 4 ViewControllers using separate xib files.
I had a UITableView that couldn't find the appropriate ViewController class I'd created until I selected the appropriate tab (not the tab item / image) and selecting the appropriate class under identity -> class identity -> class.
It then worked like a charm
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Feb 2010
Status:
Offline
|
|
I have a this situation, a navcontroller, tab controller, and View Controller, and in the first tab view coltroller in interface I added a pushbutton. All is work, but when i try to push button i will get the error "unrecognized selector sent to instance UIViewController".
Anybody know?
Originally Posted by robertjd
I'd like to make note of another situation where this problem can occur:
When using Interface Builder, if you have setup a Navigation Controller and if the View Controller that is nested in the nav controller is in a different XIB file, you will need to make sure to set the Class for the View Controller where it shows up nested in your Navigation Controller AND on the File Owner in the other XIB. If you don't have the class specified in both places, you will get the unrecognized selector error.
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jul 2002
Status:
Offline
|
|
Originally Posted by ovycom
I have a this situation, a navcontroller, tab controller, and View Controller, and in the first tab view coltroller in interface I added a pushbutton. All is work, but when i try to push button i will get the error "unrecognized selector sent to instance UIViewController".
Anybody know?
Only thing I can suggest is to make sure your class in IB is pointing to the class that has your button's IBAction:
Then simply control-click-drag from your button to your class in IB and select the IBAction:
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2010
Status:
Offline
|
|
Hi, I have the same problem...
My app has a tab view with 3 view controller and a nav controller.
In the nav controller i have put a view controller and a external nib, all is ok I can start my app and navigate through the tab nav.
When I try to put an action on a button in my nib file (in my nav controller), I got the error above...
I have my own view controller for this nib and the action in it... I have linked it in IB on the button...
And the only action is NSLOG(@"test")...
I've been looking for it on the net for last 3 days, I'm going mad...
Can someone please help me ?
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2010
Status:
Offline
|
|
oups... sorry for the noise...
my declaration in the .h was mistaken...
All is ok now...
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2010
Status:
Offline
|
|
So what was your mistake in .h file? I am running into a similar problem for a button in a subview. It seems that I have followed everything suggested here, i.e., the delegate connection, class identity. I loaded the subview via xib file and manually added to the parent view. I don't know if that's a problem. Any help is much appreciated!
Originally Posted by eqajize
oups... sorry for the noise...
my declaration in the .h was mistaken...
All is ok now...
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: May 2011
Status:
Offline
|
|
God bless you man
I had the same problem but with the Tab Bar Controller. The class was not specified in the Interface Builder for that specific view controller.
Half a day of frustrations is gone
Cheers
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status:
Offline
|
|
Real programmers don't use IB; they do it all in code.
IB is nothing but a pain-in-the-a$$.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Aug 2011
Status:
Offline
|
|
This thread is been going for a little while and the song remains the same
I had such a simple GUI : tabcontroller and 3 views so I used IB and got the actual code to process the stuff worked out, so I said not so bad for the IB .. NOT quite I tried to add a 4th View now this thing popped ...or is it pooped out of nowhere it is not taking the links and wrong key, unrecognised selector,blah blah blah
Not worth it trying to figure out my App was almost done so did this view and next ones by hand and all is good. Actually IB can be used to get the coordinates and stuff but that's it for heavy duty stuff it doesn't cut it. nib2obj comes in handy to get the code behind a GUI layout. So agreed real-coders don't use that or just use it as a reference.
Cheers
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Aug 2011
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2012
Status:
Offline
|
|
If you use Tab Bar Controller that cause this problem, please try click Tab Bar Controller's button and select Custom Class.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: May 2013
Status:
Offline
|
|
Originally Posted by YenZi
I had the same problem that was described in this thread. After quite some time I noticed, that in the inspector (right most tab "identity") for my ViewController the class was still set to "UIViewController" instead of the ViewController that contained the IBAction method. So, it's not only setting the File's owner in your nib window to your ViewController class, but also you need to set the class of the ViewController to your particular one, not the UIViewController. Look for the ViewController in your MainWindow.xib, select it, open the inspector and change class in the identity tab.
HTH,
YenZi
i had exactly the same problem, and YenZi's solution solved it, but it took me awhile to understand exactly what YenZi meant...i was going to each of my custom controllers for my tabs and trying to make the change, and that's not the problem...you have to go to your tab view controller class...when i looked at the objects in that class, i.e. the root controller nib, i saw that those objects were all listed as UIViewControllers...so i selected each ViewController, and then went to the Identity Inspector, and changed the class of each of these to my custom class, and then everything worked fine...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|