我想用两个UIViews
segmentControl
。现在这两个UIViews
都嵌入了own.These UIViews
应该的scrollView
显示为一台之间切换,所以我把它们放在对方(在XIB)的顶部。而当点击segmentControl
时,我试图相应地隐藏/显示它们。但到目前为止,我无法在两者之间切换。下面还尝试了解决方案。但它只适用于随机单元,并且无法在所有单元中切换。缺少什么?如何通过使用段控制ios在两个UIViews之间正确切换?
这就是我如何设置隐藏在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的expandedCell上单击我正在执行以下操作。
-(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;
}
}
是的,我也想过这件事。不幸的是,我的视图和我的扩展表单元格一样,现在放在XIB中。如果这种情况甚至可能,我如何添加子视图。 – iSD 2014-09-04 13:15:07
你可以将它们拆分成单独的nib,然后通过这样做来为每个nib创建一个子视图控制器:UIViewController * viewController = [[UIViewController alloc] initWithNibName:@“myNib”bundle:nil]; – pmacro 2014-09-04 13:28:00
尝试解决您的问题。我有一个问题,因为我正在使用当前实现填充当前视图控制器中的视图。我可以从我的父视图控制器填充childViewControllers视图,然后加载它们?还是要做其他事情? – iSD 2014-09-05 11:47:56