我想在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 {
....
}
答案 0 :(得分:0)
无法在屏幕上的其他位置使用自己的键盘作为标准键盘。