Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone xcode 4-带有两个文本字段的自定义键盘_Iphone_Xcode_Keyboard_Xcode4.2_Textfield - Fatal编程技术网

Iphone xcode 4-带有两个文本字段的自定义键盘

Iphone xcode 4-带有两个文本字段的自定义键盘,iphone,xcode,keyboard,xcode4.2,textfield,Iphone,Xcode,Keyboard,Xcode4.2,Textfield,我创建了一个自定义键盘,有两个文本字段。当用户单击其中一个按钮时,将显示键盘 我如何知道哪个文本字段当前处于活动状态,以便写入用户在键盘上键入的内容?我将这样做: 标记两个文本字段或使用属性 textField1.tag = 100; textField2.tag = 101; 还设置了他们的代表 textField1.delegate = self; textField2.delegate = self; 在.h文件中声明类将实现UITextFieldDelegate协议 在电视上 - (

我创建了一个自定义键盘,有两个文本字段。当用户单击其中一个按钮时,将显示键盘


我如何知道哪个文本字段当前处于活动状态,以便写入用户在键盘上键入的内容?

我将这样做:

标记两个文本字段或使用属性

textField1.tag = 100;
textField2.tag = 101;
还设置了他们的代表

textField1.delegate = self;
textField2.delegate = self;
在.h文件中声明类将实现UITextFieldDelegate协议

在电视上

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField.tag == 100) //you should use a constant instead of 100
    {
        //set a breakpoint here so you would know your typing the first textField
        return YES;
    }
}

在.h文件上声明您的类将实现UITextFieldDelegate是什么意思Protocol@interfaceYourViewController:UIViewController