Objective c 如何正确使用自己的键盘和uitextfields

Objective c 如何正确使用自己的键盘和uitextfields,objective-c,keyboard,uitextfield,Objective C,Keyboard,Uitextfield,我想用我自己的键盘类和textfield。如何简单正确地使用它 现在我有了这样的东西: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:overlay]; CGRect lRect = CGRectMake(location.x,

我想用我自己的键盘类和textfield。如何简单正确地使用它

现在我有了这样的东西:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:overlay];


CGRect lRect = CGRectMake(location.x, location.y, 1, 1);
if (CGRectIntersectsRect(lRect, self.tc.frame)) {
    textFieldID = self.tc.tag;
}

if (CGRectIntersectsRect(lRect, self.tm.frame)) {
    textFieldID = self.tm.tag;
}

if (CGRectIntersectsRect(lRect, self.tp.frame)) {
    textFieldID = self.tp.tag;
}
string = [NSMutableString stringWithString:@"0"];
}
但是我的文本字段被禁用,uiview将在文本字段上方的位置检测选中的文本字段

-(UITextField *)initializeTextFieldWithFrame:(CGRect)frame andTag:(Byte)tag {
UITextField *tf = [[UITextField alloc] initWithFrame:frame];
[tf setBackgroundColor:[UIColor colorWithRed:52.0/255.0 green:114.0/255.0 blue:151.0/255.0 alpha:1.0]];
[tf setTextColor:[UIColor whiteColor]];
[tf setFont:[UIFont fontWithName:@"Helvetica" size:18.0]];
[tf setTextAlignment:UITextAlignmentCenter];
[tf setBorderStyle:UITextBorderStyleRoundedRect];
[tf setDelegate:self];  
[tf setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[tf setEnabled:NO];
[tf setTag: tag];
[tf setText:@"0.0"];
[self insertSubview:tf atIndex:0];

return tf;
}

-(void)write:(id)sender {
....
}

没有将自己的键盘用作屏幕上其他位置的标准键盘的方法。

如何才能做到这一点?我在uitextfield中单击,我的自定义键盘会像原始键盘一样显示在屏幕上?您可以将文本字段的inputView设置为自定义视图,当它成为第一个键盘时,它会自动为您显示您的键盘响应者。请注意,行
[tf setEnabled:NO]使其不会激活,尽管…@Inafziger-是的,但当我将键盘设置为inputView时,键盘视图将扩展为正常键盘大小。我想把键盘放在屏幕中央。我该怎么做?