iPhone文本字段显示光标

iPhone文本字段显示光标

本文介绍了iPhone文本字段显示光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iphone开发计算器.设计与此类似:

i'm developing a calculator for iphone. The design is similar to this:

问题是我无法在textField中显示光标,因为输入是通过图像之类的按钮进行管理的.而且[textField成为FirstResponder]不起作用,因为它显示了默认键盘.

The problem is that i can't show the cursor in my textField because the input is managed from buttons like the image. Moreover [textField becomeFirstResponder ] doesn't work because it shows the default keyboard.

所以我试图

textResultado.inputView = scrollView;

,但是tabBarController无法接收触摸事件,因为滚动视图中包含的自定义键盘位于其上方.

but then the tabBarController can't receive touch events because my custom keyboard contained in the scroll view is over it.

标题来自AppStore中的一个应用程序,因此必须是解决此问题的一种方法(使用其他inputView和tabBar在TextField中显示光标,并且工作正常).

The caption is from an app in the AppStore so must be a way in order to solve this problem (show the cursor in a TextField using a different inputView and the tabBar still working fine).

有人可以帮助我吗?

推荐答案

创建一个不可见的输入视图,然后将 textResultado 作为第一响应者.

Create an input view which is invisible and then make textResultado the first responder.

textResultado.inputView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
[textResultado becomeFirstResponder];

这篇关于iPhone文本字段显示光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 16:07