我有一个包含10个部分的tableview,每个部分在UITableviewcell中都有一个滚动视图。
情况 - > Scrollview不可滚动,tableview正在向上/向下滚动。
问题 - > 当用户开始在scrollview内部滚动时,tableview不会滚动或侦听滚动。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifier = @"CellIdentifier";
UITableViewCell* result = [_tblMainTable dequeueReusableCellWithIdentifier:identifier];
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
CGRect frame = [_tblMainTable rectForRowAtIndexPath:indexPath];
NSLog(@"Main row height : %f", frame.size.height);
[result setFrame:CGRectMake(0, 0, mainWidth, frame.size.height)];
result.selectionStyle=UITableViewCellSelectionStyleNone;
CGFloat popHeight=frame.size.height-100;
//show and hide rows here
UIView *uvContentView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, mainWidth, frame.size.height)];
//UIView *uvContentView=[[UIView alloc] init];
[result addSubview:uvContentView];
if ([[dictIndexPaths valueForKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]] isEqualToString:@"YES"])
{
uvContentView.hidden=YES;
//imgSelectedCellImage=@"plus.png";
}else{
uvContentView.hidden=NO;
//imgSelectedCellImage=@"minus.png";
UIView *popView=[utility createView:0 forY:0 forW:mainWidth forH:180 backColor:[UIColor clearColor]];
if (indexPath.section==0) {
NSLog(@"contact Table Height %f\n ContentView Height %f",frame.size.height,uvContentView.frame.size.height);
objContactInfo.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objContactInfo.backgroundColor=[UIColor blackColor];
objContactInfo.formId=formId;
[uvContentView addSubview:objContactInfo];
[uvContentView addSubview:[utility createView:0 forY:290 forW:mainWidth forH:20 backColor:[UIColor blackColor]]];
[uvContentView addSubview:[utility createView:0 forY:345 forW:mainWidth forH:20 backColor:[UIColor blackColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:180 forW:mainWidth-mainCenter forH:110 backColor:[UIColor blackColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:740 forW:mainWidth-mainCenter forH:140 backColor:[UIColor blackColor]]];
[uvContentView addSubview:popView];
}
else if (indexPath.section==1){
//objBasisDesc.center=CGPointMake(0, 61);
objBasisDesc.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objBasisDesc.formId=formId;
[uvContentView addSubview:objBasisDesc];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:135 backColor:[UIColor clearColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:190 forW:mainWidth-mainCenter forH:715 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==2){
objAdressProp.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objAdressProp.formId=formId;
[uvContentView addSubview:objAdressProp];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:160 backColor:[UIColor clearColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:215 forW:mainWidth-mainCenter forH:165 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==3){
objNameOfPerson.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objNameOfPerson.formId=formId;
[uvContentView addSubview:objNameOfPerson];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:260 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==4){
objWitness.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objWitness.formId=formId;
[uvContentView addSubview:objWitness];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:260 backColor:[UIColor clearColor]]];
[uvContentView addSubview:[utility createView:0 forY:590 forW:mainWidth forH:20 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==5){
objTypeofHouse.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objTypeofHouse.formId=formId;
[uvContentView addSubview:objTypeofHouse];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:310 backColor:[UIColor clearColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:420 forW:mainWidth-mainCenter forH:450 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==6){
objComplaintSum.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objComplaintSum.formId=formId;
[uvContentView addSubview:objComplaintSum];
[uvContentView addSubview:[utility createView:0 forY:0 forW:mainWidth forH:177 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==7){
objRelatedQues.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objRelatedQues.formId=formId;
[uvContentView addSubview:objRelatedQues];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:640 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==8){
popHeight=popHeight-50;
objSignDate.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objSignDate.formId=formId;
[uvContentView addSubview:objSignDate];
[uvContentView addSubview:[utility createView:0 forY:0 forW:mainWidth forH:112 backColor:[UIColor clearColor]]];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:312 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==9){
objLearnedAbout.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
objLearnedAbout.formId=formId;
[uvContentView addSubview:objLearnedAbout];
[uvContentView addSubview:[utility createView:mainCenter forY:0 forW:mainWidth-mainCenter forH:360 backColor:[UIColor clearColor]]];
}
else if (indexPath.section==10){
objPhotoOrVideoVC.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
[uvContentView addSubview:objPhotoOrVideoVC];
}
else if (indexPath.section==11){
//objNameOfPerson.frame=CGRectMake(0, 0, mainWidth, uvContentView.frame.size.height);
//[uvContentView addSubview:objNameOfPerson];
}
}
// result.userInteractionEnabled=NO;
return result;
}
答案 0 :(得分:1)
在uitableview中使用xib作为tablecell。使用xib的自由形式,并根据xib的高度设置表格单元格的高度。