I'm using iOS5 SDK. I'm trying to port my iphone app to iPad. I've convert the view to be for iPad. The app is running correctly except when i want to use my custom keyboard. The keyboard is showing but when i touch button there is error unrecognized selector sent to instance. I've read a lot of articles but i can't fix the problem and i'm asking for you help.
CustomKeyboardViewController.h
Code:
#import <UIKit/UIKit.h>
#import "ScorerViewController.h"
@interface CustomKeyboardViewController : UIViewController {
UITextField *textField;
ScorerViewController *scorerController;
}
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) ScorerViewController *scoreController;
-(IBAction)number1Pressed:(id) sender;
-(IBAction)number2Pressed:(id) sender;
-(IBAction)number3Pressed:(id) sender;
-(IBAction)number4Pressed:(id) sender;
-(IBAction)number5Pressed:(id) sender;
-(IBAction)number6Pressed:(id) sender;
-(IBAction)number7Pressed:(id) sender;
-(IBAction)number8Pressed:(id) sender;
-(IBAction)number9Pressed:(id) sender;
-(IBAction)number0Pressed:(id) sender;
-(IBAction)deleteButtonPressed:(id) sender;
-(IBAction)plusButtonPressed:(id) sender;
@end
CustomKeyboardViewController.h
Code:
#import "CustomKeyboardViewController.h"
@implementation CustomKeyboardViewController
@synthesize textField;
@synthesize scoreController;
- (void) addNumber:(NSString*) number {
if([textField.text length] <= 0)
textField.text = number;
else if ([textField.text length] < 3)
textField.text=[textField.text stringByAppendingString:number];
}
-(IBAction)number1Pressed:(id)sender {
NSLog(@"\nNumber1 pressed\n");
[self addNumber: @"1"];
}
-(IBAction)number2Pressed:(id)sender {
[self addNumber: @"2"];
}
-(IBAction)number3Pressed:(id)sender {
[self addNumber: @"3"];
}
-(IBAction)number4Pressed:(id)sender {
[self addNumber: @"4"];
}
-(IBAction)number5Pressed:(id)sender {
[self addNumber: @"5"];
}
-(IBAction)number6Pressed:(id)sender {
[self addNumber: @"6"];
}
-(IBAction)number7Pressed:(id)sender {
[self addNumber: @"7"];
}
-(IBAction)number8Pressed:(id)sender {
[self addNumber: @"8"];
}
-(IBAction)number9Pressed:(id)sender {
[self addNumber: @"9"];
}
-(IBAction)number0Pressed:(id)sender {
[self addNumber: @"0"];
}
-(IBAction)deleteButtonPressed:(id)sender {
if ( [textField.text length] > 0 )
textField.text = [textField.text substringToIndex:[textField.text length] - 1];
}
-(IBAction)plusButtonPressed:(id)sender {
[scoreController addScore];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
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)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
@end
function where i add the custom view:
Code:
- (void) putCustomKeyBoardToCell: (ScoreCell *) cell {
CustomKeyboardViewController *customKeyboard1 = [[CustomKeyboardViewController alloc] initWithNibName:@"CustomKeyboardViewController" bundle:nil];
customKeyboard1.scoreController = self;
customKeyboard1.textField = cell.scoreToAddPlayer1;
cell.scoreToAddPlayer1.inputView = customKeyboard1.view;
CustomKeyboardViewController *customKeyboard2 = [[CustomKeyboardViewController alloc] initWithNibName:@"CustomKeyboardViewController" bundle:nil];
customKeyboard2.scoreController = self;
customKeyboard2.textField = cell.scoreToAddPlayer2;
cell.scoreToAddPlayer2.inputView = customKeyboard2.view;
}
ScoreCell- custom cell
scoreToAddPlayer1, scoreToAddPlayer2 - UITextField.