当我点击图像并使用键盘显示我触摸过的字母并将它们存储在变量 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 );