I am trying to get a pop up menu on iPhone.
The main app is using storyboard, but the pop up is a separate xib file that I load:
menu = [[UIViewController alloc] initWithNibName:#"SimpleMenuController" bundle:nil];
[self.view addSubview:menu.view];
and I slide it in and out with animation when pressing a button.
that works fine, but I get a problem when I try to press a button inside that pop up menu
I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIViewController PressCategory:]:
unrecognized selector sent to instance 0x8d3c040'
I have connected the button to PressCategory function
I have connected the view to the file owner.
What I have noticed is that my ViewController is called SimpleMenuViewController, that is where the PressCategory function is, so of course it will not find the selector. But I don't know what I am doing wrong in connecting in the xib file.
Change your code to:
menu = [[SimpleMenuViewController alloc] initWithNibName:#"SimpleMenuController" bundle:nil];
so that you're instantiating the correct class.
Do you have PressCategory function in your SimpleMenuViewController?
If yes, then check weather its parameterized or not.
Declare function in .h file like this:
-(IBAction)PressCategory:(UIButton *)sender;
Define it in .m file like this:
-(IBAction)PressCategory:(UIButton *)sender {
// write your code here
}
Related
I have two view controllers that both return to the home VC using
[self dismissModalViewControllerAnimated:NO];
One of them works and triggers it using a storyboard created button, whilst the one that doesn't work triggers it using a programmatically created button.
When the button on the second one is pressed it does move to the home VC, but instantly crashes
Update:
New Output
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_questioner_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTYxYWQ0YjBlMTY1MGIwZjZlMDA5NDkxNmI2MzQxZmFhBjsAVA%3D%3D--15054ec7f94935cfc07bad559f1d52cd65ea5e4b: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: scoringData
Observed object:
It seems to crash when it gets to this point
+(void)processScoringData:(NSMutableData*)response
{
[DataStore dataStore].scoringData = [[NSMutableDictionary alloc]init];
After adding an exception break point I get this beside the output. Not sure if it helps?
ServerInterface
(Class) [0] = <error: unknown Class>
response = (NS MutableData*)
NSData NSData
NSObject NSObject
isa Class 0x3c35b9ac
[0] Class <error: unknown Class>
[self dismissViewControllerAnimated:NO completion:nil]; use instead of your dismiss controller method because your method is deprecated.
Definitely work for You.
Having read this thread, I'm trying to insert a link to an external web page calling an action upon touch inside on a button (button created in storyboard with xCode 4.6).
This is the action:
-(IBAction)outLink:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"https://www.mysite.com/index.php"]];
}
and this the header file (.h):
#interface MenuViewController : UIViewController <UITableViewDataSource, UITabBarControllerDelegate>{
IBOutlet UIButton *linkToSite;
}
-(IBAction)outLink;
I have linked the button to the element in the storyboard, and I've linked the action to the Touch Up Inside event, but I get this error when I click in the simulator on the button:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MenuViewController outLink]: unrecognized selector sent to instance 0x717d340'
Change method name in .h class and reconnect your outlet for touchupinside event.
-(IBAction)outLink:(id)sender;
Hope it helps you.
I have everything implemented, and the following method that fires when I return to the source view controller:
- (IBAction)returned:(UIStoryboardSegue *)segue {
...
}
I want to take the value from the UITextField in the view I'm returning from, and set a value in my source view (or the view that calls this method) to the value of that UITextField.
I tried this:
- (IBAction)returned:(UIStoryboardSegue *)segue {
AddTextViewController *returnedFromViewController = segue.destinationViewController;
NSString *inputtedText = returnedFromViewController.textField.text;
self.foo = inputtedText;
}
But I get this error:
[RootViewController textField]: unrecognized selector sent to instance 0x8dc0250
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController textField]: unrecognized selector sent to instance 0x8dc0250'
What am I doing wrong in that code above? There's hardly any documentation on this, so it's very hard to search around myself.
You're using the wrong controller. You want the segue's sourceViewController, not the destinationViewController. Otherwise, you're doing it all correctly.
The best way to do this is to implement a protocol / delegate. The delegate will handle any requests from your destination view controller and send the data back to your source view controller.
http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html
I'm using Action Sheet Picket. I added .h and .m files as instructed in readme, picker and even cancelAction is working well but somehow successAction throws NSInvalidArgumentException with this message: "unrecognized selector sent to instance".
Application is a kind of tab bar application with Navigation Controller. There is a TabBarController as root and there are ViewControllers which are located under the TabBarController and one of the ViewControllers is a Navigation Controller. But I'm not getting this error in Navigation Controller. I'm not sure if this causes any error.
Here how I used:
- (IBAction)filterResult:(id)sender {
[ActionSheetStringPicker showPickerWithTitle:#"Pick Filter" rows:self.filterList initialSelection: self.selectedIndexes target:self successAction:#selector(animalWasSelected:element:) cancelAction:nil origin: self];
}
- (void)animalWasSelected:(NSNumber *)selectedIndex element:(id)element {
self.selectedIndexes = [selectedIndex intValue];
NSLog(#"Selected");
}
Yes that's all. I've already included ActionSheetPicker.h file and as I said picker is working fine.
Finally here is error:
[MYYViewController successAction:]: unrecognized selector sent to instance 0x9032400
2012-12-24 12:14:45.488 Example[54268:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MYYViewController successAction:]: unrecognized selector sent to instance 0x9032400'
Any help would be great.
Looks rather straight forward, you need to implement successAction: in your MYYViewController class, because the picker is not checking if it will respond or not and calling it directly.
I have an UIViewController with several subviews in its view property (UISearchbar and several UIButtons). The UIButtons hooked up to typical IBActions like -(IBAction)buttonPressed:(id)sender for the UIControlEventTouchUpInside state - it doesn't matter if I do it in IB or programmatically.
- (void)viewDidLoad {
MUZTitleViewController *title = [[MUZTitleViewController alloc]
initWithNibName:nil bundle:nil];
self.navigationItem.titleView = title.view;
}
In my project there's also an UINavigationController. When I set the navigationItem.titleView of the UINavigationBar to the view of my UIViewControllers view I get an EXC_BAD_ACCESS exception, as soon as I tap one of the button. I don't know why this is.
I uploaded a small sample project to illustrate my problem: Test010.xcodeproj (it's ARC enabled)
More and more I come to the conclusion that it's not a good idea to use the UIViewControllers view and assign it to the titleView but I don't see any alternative here.
Edit: Sorry, the sample project commented out the call which causes the exception. I reuploaded the linked project file.
Edit^2: As PengOne pointed out I've skipped the exact error message I got:
2011-09-10 23:09:50.621 Test010[78639:f803] -[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0
2011-09-10 23:09:50.623 Test010[78639:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0'
Have you tried setting NSZombieEnabled to YES? If I do this, the console shows the following output:
2011-09-10 22:56:23.329 Test010[6481:ef03] *** -[MUZTitleViewController
performSelector:withObject:withObject:]: message sent to deallocated
instance 0x7a7ff70
As the project is ARC enabled, the controller seems to get deallocated some time after this line:
MUZTitleViewController *title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
I am not sure what the best solution is, but a property definitely helps to prevent the exception like so:
// MUZDetailViewController.h
#property (strong, nonatomic) MUZTitleViewController *title;
// MUZDetailViewController.m
#synthesize title;
self.title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
self.navigationItem.titleView = title.view;
The problem that you were having with ARC can also be resolved by setting the initial view controller of your application as your main window's rootViewController property instead of using addSubview.
Doing this avoids the need to add each custom view controller as a property.