0

我想在文本字段中使用我自己的键盘类。我怎样才能简单而正确地使用它?

现在我有这样的东西:

-(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 {
....
}
4

1 回答 1

0

无法在屏幕上的其他位置使用自己的键盘作为标准键盘。

于 2012-06-27T18:00:34.670 回答