【发布时间】:2011-07-18 12:28:58
【问题描述】:
我从另一个 UITableViewController 类(比如 Table1)创建并呈现一个 UITableViewController(比如 Table2)类,就像这样..
-(void)createTable2 {
Table2Controller *table2Controller = [ [Table2Controller alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:table2Controller];
[self.navigationController presentModalViewController:nav animated:YES];
[nav release];
[table2Controller release];
}
所以 Table2 将显示出来。我想使用 touchesBegan 方法在 Table2 中退出键盘,因为我有一些 UITextField 作为单元格。我在 Table2 的 .h 文件中包含了 UITextFieldDelegate 协议。
但我知道这些 touchesBegan 方法仅适用于 UIView 而不适用于 UIViewController(对吗?)。但是我不知道在哪里以及如何(我在 createTable2 函数本身中尝试过。它不起作用)添加一个 UIView,然后在该 UIView 中添加 Table2 以使事情发生......任何建议......
【问题讨论】:
-
在单元格中添加 UItextfield 时,只需添加 txt.delegate=self;然后覆盖 UITextFieldDelegate 方法。你可以使用 -touchesBegan:withEvent:)
-
对不起,我也忘了添加这个。我已经添加了你的线路。但它没有得到调用
-
哪个方法没有被调用...UITextFieldDelegate 方法或 touchesBegan
-
您为什么不为此目的使用 tableview 委托?
标签: iphone uiview uinavigationcontroller uitableview touchesbegan