用于在自定义 uitableview 单元格中输入的自定义键盘
我有一个包含表视图的视图(我将此视图称为 EquationView,其控制器称为 EquationViewController)。表视图单元格是带有标签和文本字段的自定义单元格,分别代表变量及其值。当在文本字段中开始编辑时,我已经能够显示自定义键盘。
但是,我无法让击键出现在正确的单元格中,因为我无法弄清楚如何将正在编辑文本字段的单元格的索引路径发送到自定义键盘控制器类。我已将 EquationViewController.h 文件包含在自定义键盘控制器类中,并且能够通过手动将 indexPath 设置为指定行来更改 tableview 的 textFields 中的文本。这是键盘类定义:
#import <UIKit/UIKit.h>
#import "EquationViewController.h"
@interface CustomNumberPadViewController : UIViewController {
EquationViewController *equationViewController;
}
@property (nonatomic, retain) EquationViewController *equationViewController;
-(IBAction)buttonPressed:(id)sender;
@end
我的操作方法如下所示(到目前为止):
-(IBAction)buttonPressed:(id)sender{
VariableCell *cell = (VariableCell *)[equationDetailViewController.myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.variableValue.text = @"test";
}
这使得单词“test”出现在我在索引路径中设置的任意行上。
所以我想知道的是,有没有办法将其 textField 正在编辑的单元格的索引路径传递/获取到我的自定义键盘控制器类中的操作方法?
I have a view which contains a tableview, (i call this view the EquationView, and its controller the EquationViewController). The table view cells are custom cells with a label and a textfield, representing a variable and its value, receptively. I have been able to get my custom keyboard to apear when editing begins in the textfield.
However, I haven't been able to get the keystrokes to apear in the correct cell, do to the fact that I haven't been able figure out how to send the indexPath of the cell with textfield being edited to the custom keyboard controller class. I have included my EquationViewController.h file in my custom keyboard controller class and have been able to change the text in the tableview's textFields by manually setting the indexPath to a specified row. Here is the keyboard class definition:
#import <UIKit/UIKit.h>
#import "EquationViewController.h"
@interface CustomNumberPadViewController : UIViewController {
EquationViewController *equationViewController;
}
@property (nonatomic, retain) EquationViewController *equationViewController;
-(IBAction)buttonPressed:(id)sender;
@end
My action method looks like this (so far):
-(IBAction)buttonPressed:(id)sender{
VariableCell *cell = (VariableCell *)[equationDetailViewController.myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.variableValue.text = @"test";
}
This get the word "test" to appear on whichever row I set in the index path.
So what I'm wondering is, is there a way to pass/get the indexPath of the cell whose textField is being edited to the action method in my custom keyboard controller class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将 UIViewController 设置为 UITextFields 的委托并捕获 textFieldDidBegin: 委托方法?
Why don't you set your UIViewController as the delegate of your UITextFields and catch the textFieldDidBegin: delegate method?