【发布时间】:2014-09-05 20:59:42
【问题描述】:
我正在尝试使用segmentControl 在两个UIViews 之间切换。现在这两个UIViews 都嵌入了它们自己的scrollView。这些UIViews 应该显示为一个,所以我已经放置了它们在彼此之上(在XIB中)。当点击segmentControl时,我试图相应地隐藏/显示它们。但到目前为止,我无法在两者之间切换。还尝试了下面建议的解决方案。但是它只适用于 random 单元格并且无法在所有单元格中切换。缺少什么?
这就是我设置隐藏在 didSelectRow 中的上部视图的方式,我在其中展开 tableViewCell 。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if ([self.expandedCells containsObject:indexPath]) {
expCell.upperContainer.hidden = NO;
expCell.upperScroll.hidden = NO;
[self.expandedCells removeObject:indexPath];
}else{
isExpanded=YES;
[self.expandedCells addObject:indexPath];
//hide upper container
if (!expCell.upperContainer.hidden) {
expCell.upperContainer.hidden = YES;
}
if (!expCell.upperScroll.hidden) {
expCell.upperScroll.hidden =YES;
}
}
[self.bTableView beginUpdates];
[self.bTableView reloadData];
[self.bTableView endUpdates];
}
在 segmentControl 上的 expandCell 中单击我正在执行以下操作。
-(void)selectDeckView:(UISegmentedControl*)sender{
if (sender.selectedSegmentIndex==0) {
NSLog(@"segment 0"); //executes
expCell.lowerDeckView.hidden=NO;
expCell.lowerScrollView.hidden=NO;
expCell.upperScroll.hidden=YES;
expCell.upperContainer.hidden=YES;
}else if (sender.selectedSegmentIndex==1){
NSLog(@"segment 1"); //executes
expCell.lowerDeckView.hidden=YES;
expCell.lowerScrollView.hidden=YES;
expCell.upperContainer.hidden=NO;
expCell.upperScroll.hidden=NO;
}
}
【问题讨论】:
标签: ios objective-c uitableview uiview uisegmentedcontrol