我尝试实施customkeyboard用的UISearchBar。首先我所有mainclass.h在哪里我使用的UISearchBar是这个样子
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@class PashtoKeyboard;
@class SearchBar;
@interface MainViewController : UIViewController<UISearchBarDelegate > {
IBOutlet SearchBar *searchBar;
PashtoKeyboard *pashtoKeyboard;
}
@property(nonatomic,retain) PashtoKeyboard *pashtoKeyboard;
@property (nonatomic,retain) SearchBar *searchBar;
@end
现在我mainclass.m
#import "MainViewController.h"
#import "PashtoKeyboard.h"
#import "SearchBar.h"
@implementation MainViewController
@synthesize pashtoKeyboard,searchBar;
- (void)viewDidLoad
{
[super viewDidLoad];
//Create Pashto Keyboard
PashtoKeyboard *pashtoKey = [[PashtoKeyboard alloc] initWithFrame:CGRectMake(0.0, 460.0-216.0, 320.0, 216.0)];
[pashtoKey loadView];
//[self.view addSubview:hebKey];
[pashtoKey addTarget:self action:@selector(pashtoKeyboard_clicked:) forControlEvents:1001];
[pashtoKey addTarget:self action:@selector(pashtoKeyboardBackspace_clicked:) forControlEvents:1002];
[pashtoKey addTarget:self action:@selector(pashtoKeyboardEnter_clicked:) forControlEvents:1003];
[self setPashtoKeyboard:pashtoKey];
//[hebKey setHidden:YES];
[pashtoKey release];
searchBar.inputView = pashtoKey;
searchBar.delegate=self;
searchBar.userInteractionEnabled=YES;
}
#pragma mark Pashto Keyboard Methods
- (void) pashtoKeyboard_clicked:(id)sender{
[searchBar setText:[pashtoKeyboard keyboardText]];
}
- (void) pashtoKeyboardBackspace_clicked:(id)sender{
[searchBar setText:[pashtoKeyboard keyboardText]];
}
- (void) pashtoKeyboardEnter_clicked:(id)sender{
[searchBar setText:[pashtoKeyboard keyboardText]];
}
在SearchBar.h
#import <UIKit/UIKit.h>
@interface SearchBar : UISearchBar {
}
@property (readwrite, retain) UIView *inputView;
@end
在SearchBar.m
#import "SearchBar.h"
@implementation SearchBar
@synthesize inputView;
- (void)dealloc {
[super dealloc];
}
@end
然后最后我有PashtoKeyboard.h和PashtoKeyboard.m哪里创建我的自定义键盘,由于大的编码不是我在这里展示这些类的代码,我测试了它与textveiw和文本框。 但它不工作的UISearchBar一些。可一个指导我怎么做this.thanx