나는 UIScrollView
에서 UITableView
및 UIButton
를 추가하고있다. 버튼이 tableview 아래에 배치됩니다.UIScrollView의 높이가 변경 되었습니까?
글쎄, 테이블에서 임의의 행을 선택하면 해당 행에 버튼이 추가되고 모든 것이 지금까지는 괜찮습니다.하지만 그 행을 두 번째로 클릭하면 버튼이 제거되지만 문제는 제거와 함께 표시됩니다. 그 버튼은 또한 내 테이블을 위로 스크롤하고 버튼을 눌러 테이블을 그 자리에 둔다. ie. 테이블과 버튼 사이에 틈을 남겨 둡니다. 행을 클릭 할 때마다 내 테이블이 다시로드됩니다. UITableView
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
mainTable.frame = CGRectMake(mainTable.frame.origin.x, mainTable.frame.origin.y,
mainTable.frame.size.width,
([menuItemsArray count] * 60) + 380);
[scrollView setContentSize:CGSizeMake(320,([menuItemsArray count] * 60) + 80 + 350)];
reserverBtnBottom = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[reserverBtnBottom setFrame:CGRectMake(20.0f,mainTable.frame.size.height,280, 40)];
[reserverBtnBottom addTarget:self action:@selector(reserveBtnAction) forControlEvents:UIControlEventTouchUpInside];
[reserverBtnBottom setBackgroundImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];
[reserverBtnBottom setAlpha:1];
[reserverBtnBottom setTitle:@"Reserve this table" forState:UIControlStateNormal];
[reserverBtnBottom setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[scrollView addSubview:reserverBtnBottom];
rest thing goes here
}
아래 추가 UIButton
에 대한 코드는 내가 무엇을 놓치고? 미리 감사드립니다. 이 방법은 새로운 높이를 계산하기 위해 한 번 호출 할 수있는 단일 행의 상태를 변화로
어떻게 동적 높이의 테이블 아래의 버튼을 유지하는 레이아웃을 수행합니까? 테이블 바닥 글보기를 사용하면 간단하게 만들 수 있습니다.이 방법은 답이 아닌 대안입니다. –
@ A-Live 버튼의 프레임을 설정하고 y 좌표가 테이블의 높이와 같도록 지정하고 있습니다. – Blios
버튼의 프레임은 어디에 설정합니까? heightForRowAtIndexPath 메소드의 –