0

当我点击图像并使用键盘显示我触摸过的字母并将它们存储在变量 NSString 中时,我想显示键盘。(如 Snapchat)。如何在“live”中显示字母?

我已经为我点击的位置制作了 UIGestureRecognizer 和识别器。这是我的代码:

-(void)tapDetected:(UIGestureRecognizer*)recognizer{
NSLog(@"tap detected.");
CGPoint point = [recognizer locationInView:self.truckImageView];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, point.y, 300, 40)];
[textField becomeFirstResponder];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = @"enter text";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.delegate = self;
[self.view addSubview:textField];
NSLog(@"x = %f y = %f", point.x, point.y );
4

1 回答 1

0

没有办法用 UIImage 正式显示 UIKeyboard。

当用户触摸图像时,在该点添加 UITextField 并设置 firstResponder。你甚至不需要使用 drawText:。

于 2014-07-22T01:06:37.450 回答