didSelectRowAtIndexPath 没有被调用
我在 UIViewController 中有一个 UITableView,如下所示:
.h
@interface OutageListViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> {
IBOutlet UITableView *outageTable;
.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Selected");
}
我自定义了表格单元格:
//EDIT 我在自定义视图上并排放置了 UILabel,以及遍布整个区域的背景。但是在调整大小/删除我放在自定义单元格上的背景图像和标签后,“didSelectRowAtIndexPath”仍然没有被调用。 //END EDIT
@interface AbstractSummaryListViewCell : UITableViewCell {...}
并且
@interface FiveColumnSummaryCell : AbstractSummaryListViewCell {...}
此 UIView 在另一个 UIView 内:
@interface CustomTabBarController : UIViewController {
OutageListViewController *outageListViewController;
我的 AppDelegate 将其添加到窗口中:
[window addSubview:[customTabBarController view]];
现在我试图确定哪个单元格被单击并且 didSelectRowAtIndexPath 没有被调用,我有 dataSource 和委托从 UITableView 连接到文件的所有者,实际上数据按照我的“cellForRowAtIndexPath”指定正确填充,有什么想法可以解决这个问题吗?
谢谢!
I have a UITableView inside a UIViewController like so:
.h
@interface OutageListViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> {
IBOutlet UITableView *outageTable;
.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Selected");
}
I have customized table cell:
//EDIT
I have fire UILabel side by side on my customized view, as well as a background spreading the entire area. But after resizing/removing the background image and label I putted on the customized cell, "didSelectRowAtIndexPath" is still not being called.
//END EDIT
@interface AbstractSummaryListViewCell : UITableViewCell {...}
and
@interface FiveColumnSummaryCell : AbstractSummaryListViewCell {...}
This UIView is inside another UIView:
@interface CustomTabBarController : UIViewController {
OutageListViewController *outageListViewController;
And my AppDelegate add this to the window:
[window addSubview:[customTabBarController view]];
Now I'm trying to determine which cell get clicked and didSelectRowAtIndexPath doesn't get called, I have dataSource and delegate connect from the UITableView to File's Owner, in fact the data populates correctly as my "cellForRowAtIndexPath" specifies, any ideas how can I fix this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我解决了这个问题:忘记在我的自定义单元 xib 中检查用户交互已启用。真是个傻瓜!
I solved it: forgot to check User Interaction Enabled in my customized cell xib. What a fool!
UITableView 的以下属性都是
YES
吗?编辑
:我认为保罗是对的。委托属性有一些问题。您可以在 -(void)viewDidLoad 中检查 tableView 的 delegate 属性。正如您所说,它们应该连接到 xib 中的 FileOwner。所以下面的代码不会得到nil。
Are the following properties of UITableView all
YES
?Edit
:I think Paul is right. The delegate property has some problem. You can check the delegate property of tableView inside -(void)viewDidLoad. As you said, they should be connected to FileOwner in xib. So the following codes won't obtain nil.
视图控制器可能尚未在任何地方连接到
outageTable
的delegate
属性。It's possible that the view controller has not been connected to the
delegate
property of theoutageTable
anywhere.您可以进行快速测试...删除“大”标签并查看是否调用了 didSelectRowAtIndexPath 。
You can make a quick test... Remove the "big" label and see if the didSelectRowAtIndexPath is called.