iOS - 自定义键盘,更新父视图中的文本字段
我正在实现一个自定义键盘,并且需要在触摸该键盘上的按钮时更新原始文本字段。
我尝试按照这个问题的答案: 使用自定义 inputView 将输入返回到 UITextfield 但我觉得不是很清楚。
在 statViewController 中,我定义了我的 textField xValue
,并创建了键盘的一个实例:
DCKeyboard *dckXValue = [[DCKeyboard alloc] initWithNibName:@"DCKeyboard" bundle:nil];
答案的下一行使用 self,所以我认为它建议我应该创建 dckXValue 的属性,即statViewController:
dckXValue.objStatViewController = self;
同样,我遵循答案(添加 @class
行,创建对象/属性),但随后在捕获按钮按下的方法中(在 DCKeyboard.m 中),当我到达该行:
objStatViewController.xValue.text = @"Some value";
当我尝试编译时,出现错误“请求非结构或联合中的成员‘xValue’”。
谁能给我任何关于我可能出错的地方的提示?
谢谢!
I am implementing a custom keyboard and need to update the original textField when buttons are touched on that keyboard.
I have tried following the answer to this question:
Return Inputs to UITextfield with custom inputView
but I don't find it very clear.
In statViewController I have defined my textField xValue
, and created an instance of my keyboard:
DCKeyboard *dckXValue = [[DCKeyboard alloc] initWithNibName:@"DCKeyboard" bundle:nil];
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;
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";
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?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是属性问题,文本字段不是属性。尝试在您的实现文件中#import“StatViewController.h”
It's a problem of property the text field is not a property. Try #import "StatViewController.h" in your implementation file