UITableViewCell变得没有反应
我有一个popover屏幕,里面有:
- 一个标签,可能会或可能不会出现(标题)
- 一个search栏,可能会或可能不会出现
- 一个标签,可能会或可能不会出现,并有一个可变的高度(帮助标签)
- 一个可能或不可能出现的滚动视图,并且具有可变的高度(关于下表的一些信息)
- 一张桌子视图
为了呈现一些不错的东西,在viewDidLoad
,我移动了各种框架来正确放置对象,并且没有未使用的空间混乱我的popup窗口。 此外,我然后调整表(以获得最需要的地方),并通过contentSizeInPopover
(避免有一个近乎空的巨大popover popover)的popup窗口。 所有resize似乎很好,但我有一个大问题:所有resize,我的UITableView的一些单元格变得没有响应。 一个或两个单元格,通常是第二个单元格,只有当我点击它们的外angular时才会作出响应,但是单元格的其余部分完全忽略了任何触摸。
我已经尝试了一切:移动所有viewWillAppear
,让autoresize做它的工作(似乎也不工作),但我仍然每次都有这个问题。 我发现,如果我评论涉及到更改表格frame
或contentSizeInPopover
中的问题,这个问题就会停止,但是我的视图被搞砸了,所以这不是一个修复。
如果有人能给我一些东西摆脱这个混乱,那将是非常棒的。
- (CGFloat)getHeightWithoutTable { (self.errorScrollView.hidden?0:self.errorScrollView。 frame.size.height + LIST_STD_SPACE); } - (void)viewDidLoad { [super viewDidLoad]; self.tableViewOutlet.backgroundView = nil; self.originData = [NSMutableArray array]; self.searchedData = [NSMutableArray array]; if(self.helper!= nil){ CGFloat heightOffset = 0; //内容 self.originData = [self.helper getData]; self.tableData = [NSMutableArray arrayWithArray:self.originData]; //标题 NSString * title = [self.helper getPopoverTitle]; if(title == nil){ self.popoverTitle.hidden = YES; heightOffset - = LIST_TITLE_HEIGHT; } else { self.popoverTitle.text = [self.helper getPopoverTitle]; } //search 如果([self.originData count] [self getStdHeight] / 3){ self.helpLabel.lineBreakMode = UILineBreakModeTailTruncation; [self.helpLabel sizeThatFits:CGSizeMake(self.helpLabel.frame.size.width,[self getStdHeight] / 3)]; } heightOffset + =(self.helpLabel.frame.size.height - LIST_HELP_STD_HEIGHT); } //错误 如果([self.helper respondsToSelector:@selector(getErrors)]){ self.errors = [self.helper getErrors]; } if(self.errors == nil || [self.errors count] == 0){ self.errorScrollView.hidden = YES; self.errorBg.hidden = YES; heightOffset - = LIST_ERROR_STD_HEIGHT + LIST_STD_SPACE; } else { [self createErrorView]; heightOffset + =(self.errorScrollView.frame.size.height - LIST_ERROR_STD_HEIGHT); } //表格 CGFloat previewHeight = LIST_CELL_HEIGHT * [self.tableData count] + LIST_STD_SPACE; CGFloat remainingHeight = LIST_MAX_HEIGHT - [self getHeightWithoutTable] - LIST_STD_SPACE; CGFloat tableHeight = MIN(previewHeight,remainingHeight); CGRect tableFrame = self.tableViewOutlet.frame; self.tableViewOutlet.frame = CGRectMake(tableFrame.origin.x,tableFrame.origin.y + heightOffset,LIST_WIDTH,tableHeight); //select的项目 if([helper getSelectedObject]!= nil){ int index = [self.tableData indexOfObject:[helper getSelectedObject]]; NSIndexPath * indexPath = [NSIndexPath indexPathForRow:index inSection:0]; [self.tableViewOutlet scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; } } } - (CGSize)contentSizeForViewInPopover { if(self.navigationController){ 返回CGSizeMake(LIST_WIDTH,LIST_MAX_HEIGHT); } else { CGFloat totalHeight = [self getHeightWithoutTable] + self.tableViewOutlet.frame.size.height + LIST_STD_SPACE; 返回CGSizeMake(LIST_WIDTH,totalHeight); } }
(如果你需要一些着色来帮助你,
笔尖的图像:
只是在黑暗中拍摄,因为你没有提供任何代码。 如果你正在向UITableCellView添加东西,只要记住很多组件的UserInteractionEnabled
设置为NO
,这将禁用与它交互的能力。 确保您添加到单元格的任何项目可能占用您正在轻敲的空间(大概是单元格的中心?)将其UserInteractionEnabled
设置为YES
。
边缘可能仍然工作的原因是UITableCellView由3个主要部分组成,所以你可能只是改变中心部分。
发布一些代码,然后我们可以有一个更好的看看。
我自己find了答案:我在我的UITableView旁边使用了一个自填充的UIScrollView似乎是个问题。 只要我用适当的UITableViewreplace了UIScrollView,问题就消失了。