【发布时间】:2016-03-04 10:44:50
【问题描述】:
我在 textField onEditing 事件中打开包含 Tableview 的 popupView。
我正在为 tableview 设置 DataSource 和 Delegate。 我为 Tableview 设置了这么多属性
1) 允许选择 = 是
2) userInterectionEnabled = 是
3) tableview.layer.zposition = 1
4) [self.view bringSubViewToFront: tableview]
这是代码..
UITableView *tblCompany = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UtilClass getScreenWidth]-[UtilClass getScreenWidth]/4, 200)];
tblCompany.dataSource = self;
tblCompany.delegate = self;
tblCompany.userInteractionEnabled=YES;
tblCompany.allowsSelection=YES;
tblCompany.separatorStyle=UITableViewCellSeparatorStyleNone;
[self.popOver addSubView:tblCompany];
我的问题
我的 viewController 中有很多控件,例如按钮和标签。 当我编辑我的文本字段时,弹出窗口会在按钮上打开。
当我尝试点击 tableView 的单元格时,它没有调用didSelectRowAtIndexPath,但我点击了它后面的按钮。
注意:
cellForRowAtIndexPath,numberOfRowsInSection,heightForRowAtIndexPath这些都可以正常工作,所以DataSource或Delegate没有问题注意:在我的 viewController 中没有使用任何
Gesture。
我认为图层有问题,所以我也应用了 zPosition,但不起作用..
编辑 我只是在 textField Editing 上制作 popOver view.hidden = true 或 false ..
有什么解决办法吗?
【问题讨论】:
-
您需要解释表格视图是如何呈现/添加到屏幕的,以及与您显示的其他代码相关的时间
-
您的表格视图似乎在您的按钮后面。显示 UITableview 时,使用
[self.view bringSubviewToFront:YOUR_TABLEVIEW]; -
同时检查 Debug view Hierarchy 。
-
@Wain,检查我的编辑
-
@Hima,Right Hima,我也这么认为。但我已经申请了
bringSubviewToFront& 如何调试视图层次结构?
标签: ios objective-c iphone uitableview popover