iOS - 自定义键盘,更新父视图中的文本字段 [英] iOS - Custom keyboard, updating text field in parent view

查看:33
本文介绍了iOS - 自定义键盘,更新父视图中的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个自定义键盘,需要在触摸该键盘上的按钮时更新原始 textField.

I am implementing a custom keyboard and need to update the original textField when buttons are touched on that keyboard.

我已尝试按照此问题的答案进行操作:使用自定义 inputView 将输入返回到 UITextfield但我觉得不是很清楚.

I have tried following the answer to this question: Return Inputs to UITextfield with custom inputView but I don't find it very clear.

在 statViewController 中,我定义了 textField xValue,并创建了我的键盘实例:

In statViewController I have defined my textField xValue, and created an instance of my keyboard:

DCKeyboard *dckXValue = [[DCKeyboard alloc] initWithNibName:@"DCKeyboard" bundle:nil];

答案的下一行使用 self,所以我认为它建议我应该创建 dckXValue 的属性,即 statViewController:

The next line of the answer uses self, so I take it that it's suggesting that I should create a property of dckXValue that is a statViewController:

dckXValue.objStatViewController = self;

同样,我按照答案进行操作(添加 @class 行,创建对象/属性)但是在我的方法中,当我到达时(在 DCKeyboard.m 中)捕获我的按钮按下线:

Again, I follow the answer through (add the @class line, create the object/property) but then in my method that catches my button presses (in DCKeyboard.m), when I reach the line:

objStatViewController.xValue.text = @"Some value";

当我尝试编译时,我收到错误在非结构或联合的东西中请求成员‘xValue’".

I am getting the error "Request for member 'xValue' in something not a structure or union" when I try to compile.

谁能给我任何关于我可能出错的提示?

Can anyone give me any hints on where I might be going wrong?

谢谢!

推荐答案

文本字段不是属性是属性的问题.在您的实现文件中尝试 #import "StatViewController.h"

It's a problem of property the text field is not a property. Try #import "StatViewController.h" in your implementation file

这篇关于iOS - 自定义键盘,更新父视图中的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆