【发布时间】:2010-03-26 11:05:07
【问题描述】:
当我想在我的应用程序页面的键盘(文本字段填充器)中使用自定义按钮时,我在 iphone 中遇到了问题。我在键盘中嵌入了一个名为 dot 的按钮,它看起来很好,但是当我单击它时,它应该转到我定义的操作。但它崩溃了。
- (void)sendDecimal:(id)sender {
// Post a Notification that the Decimal Key was Pressed.
[[NSNotificationCenter defaultCenter] postNotificationName:@"DecimalPressed" object:nil];
}
它一直运行到应用程序尝试向我不知道可能是例程或函数或方法发送通知。
有人可以在这方面帮助我吗?
谢谢
编辑
这是错误信息:
-[UITableView addDecimal:]: unrecognized selector sent to instance 0x4051e00
2010-03-26 16:08:42.272 app[2855:20b]
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UITableView addDecimal:]: unrecognized selector sent to instance
0x4051e00'
编辑
我已经定义了addDecimal选择器,这里是代码......
- (void)viewDidAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:tableView selector:@selector(addDecimal:) name:@"DecimalPressed" object:nil];
编辑
是的,我把它写成 [dot addTarget:self action:@selector(sendDecimal:) forControlEvents:UIControlEventTouchUpInside];
【问题讨论】:
-
您可以从控制台复制并粘贴错误消息吗?这将非常有帮助。
-
*** -[UITableView addDecimal:]:无法识别的选择器发送到实例 0x4051e00 2010-03-26 16:08:42.272 app[2855:20b] *** 由于未捕获的异常而终止应用程序' NSInvalidArgumentException',原因:'*** -[UITableView addDecimal:]:无法识别的选择器发送到实例 0x4051e00'