I have a text field in a tableview cell and I want to assign a custom input keyboard. I can get the keyboard to show up, but it seems that the corresponding controller class is not connected. When I press any button, I get a EXC_BAD_ACCESS error, or a "unrecognized selector" error.
Here is the code where I tie the tableview cell's textfield to the custom input keyboard
CustomNumberPadViewController *calcKeyboard = [[CustomNumberPadViewController alloc] initWithNibName:@"CustomNumberPadView" bundle:nil];
calcKeyboard.equationViewController = self;
cell.variableValue.inputView = calcKeyboard.view;
I have action methods tied to the buttons of the calkKeyboard, and when I press the buttons, those methods are not being called. I have even instantiated a "viewWillAppear" method which is also not being called when the keypad comes up.
I have checked the class of the numberpad and it is connected to the CustomNumberPadViewController, which contains the above mentioned methods.
Here is the code for my CustomNumberPadViewController:
#import <UIKit/UIKit.h>
#import "EquationViewController.h"
@class EquationViewController;
@interface CustomNumberPadViewController : UIViewController <UITextFieldDelegate>{
EquationViewController *equationViewController;
}
@property (nonatomic, strong) EquationViewController *equationViewController;
-(IBAction)buttonPressed:(id)sender;
-(IBAction)buttonDonePressed:(id)sender;
-(IBAction)buttonDelPressed:(id)sender;
@end
And associated implementation (for brevity I've cut out the guts of the action methods and just left my debugging logs):
#import "CustomNumberPadViewController.h"
#import "VariableCellController.h"
@implementation CustomNumberPadViewController
@synthesize equationViewController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
-(void) viewWillAppear:(BOOL)animated
{
UIColor *backgroundPatern = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"calculatorBackground.png"]];
self.view.backgroundColor = backgroundPatern;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#pragma mark - Action Methods
-(IBAction)buttonPressed:(id)sender{
NSLog(@"61-CNPVC");
}
-(IBAction)buttonDonePressed:(id)sender{
NSLog(@"117-CNPVC");
}
-(IBAction)buttonDelPressed:(id)sender{
NSLog(@"125-CNPVC");
}
@end