【发布时间】:2010-06-09 08:49:00
【问题描述】:
所以我有一个带有 UITableView 的 UIViewController 视图。 所以 UIViewController 类名是 SelectionScreen。 UITableView 类名为 SelectionScreenTable。
图片: http://img717.imageshack.us/i/screenshot20100609atpm0.png/
我在 SelectionScreen 类中声明了一个 UITableView *selectionTable 并将其连接到 SelectionScreen 的 xib 文件
问题是什么,当我单击表格中的一行时,它仍然选择为突出显示的蓝色,它调用 didSelectRowAtIndexPath(使用 NSLog 检查)但没有推送一个名为(GraphView)的新视图。
这是我用来调用带有普通按钮的新控制器的代码
GraphView *aSelectionScreenViewController = [[GraphView alloc]
initWithNibName:@"GraphView"
bundle:nil];
[self presentModalViewController:aSelectionScreenViewController 动画:YES]; [aSelectionScreenViewController 发布];
搜了一圈,发现需要在viewload的UITableView类本身中为表设置一个delegate
tableview.delegate = self;
或
self.tableview.delegate = self;
但它不起作用。控制器仍然没有被推动,是的,我已经检查了控制器不是 nil,因为我用一个简单的按钮尝试了它。
所以我在考虑是否应该在 UIViewController 上设置 UITableView 的委托,所以我尝试了这段代码
selectionTable.delegate = selectionTable.self;
但显然它不起作用=\,它弄乱了整个 UITableView 并导致所有单元格都是它的预定义设置。
那么有没有人知道我如何让它工作。
【问题讨论】: