3

我在 UIViewController 中有一个 UITableView,如下所示:

。H

@interface OutageListViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> {
   IBOutlet UITableView *outageTable;

.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   NSLog(@"Selected");
}

我有自定义表格单元格:

//编辑我在我的自定义视图上并排触发了 UILabel,以及遍布整个区域的背景。但是在调整/删除我放在自定义单元格上的背景图像和标签之后,仍然没有调用“didSelectRowAtIndexPath”。//结束编辑

@interface AbstractSummaryListViewCell : UITableViewCell {...}

@interface FiveColumnSummaryCell : AbstractSummaryListViewCell {...}

这个 UIView 在另一个 UIView 里面:

@interface CustomTabBarController : UIViewController {
   OutageListViewController *outageListViewController;

我的 AppDelegate 将其添加到窗口中:

[window addSubview:[customTabBarController view]];

现在我正在尝试确定单击了哪个单元格并且没有调用 didSelectRowAtIndexPath,我有数据源并委托从 UITableView 连接到文件的所有者,实际上数据正确填充为我的“cellForRowAtIndexPath”指定,任何想法我怎么能解决这个问题?

谢谢!

4

4 回答 4

4

我解决了:忘记在我的自定义单元格 xib 中检查用户交互已启用。真是个蠢才!

于 2011-08-02T16:44:14.120 回答
3

UITableView 的以下属性是否全部YES

  • 允许选择
  • 允许SelectionDuringEditing

Edit: 我认为保罗是对的。委托属性有一些问题。您可以在 -(void)viewDidLoad 中检查 tableView 的委托属性。正如您所说,它们应该连接到 xib 中的 FileOwner。所以下面的代码不会得到 nil。

- (void)viewDidLoad {
   [super viewDidLoad];

   // They should not be nil.
   NSLog(@"delegate:%@ dataSource:%@", self.tableView.delegate, self.tableView.dataSource);
}
于 2011-08-02T02:03:53.017 回答
2

视图控制器可能没有连接到任何地方的delegate属性outageTable

于 2011-08-02T02:58:32.220 回答
0

你可以做一个快速测试...去掉“大”标签,看看是否调用了didSelectRowAtIndexPath。

于 2011-08-02T00:13:01.567 回答