당신이 필요로하는 것은 보통의 UITableViewController
입니다 (따라서 모든 정적 셀 동작을 얻습니다). 그러면 테이블보기의 하위보기로 볼 수 있지만 항상 화면 아래쪽에 고정되도록 관리됩니다. Apple은 이것을 WWDC로 시연했습니다. 다음은 내가하는 일입니다. (필자의 예에서는 항상 하단에 고정되어있는 UIDatePicker
입니다.) :
viewDidLoad
에서보기를 만들고이를 테이블보기의 하위보기로 추가하십시오. 테이블보기의 맨 아래에 놓습니다.
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
// Keep the date picker floating above the table view, anchored to the bottom of the view
[self updateDatePickerBounds];
}
그리고 제대로보기를 배치하는 기능 구현 :
을
[self.tableView addSubview:self.datePicker];
[self updateDatePickerBounds];
당신은 테이블 뷰 스크롤 이제까지 스크린 시간의 바닥에보기를 강제 할 수 있도록 scrollViewDidScroll
구현
- (void) updateDatePickerBounds
{
// Keep the date picker floating above the table view, anchored at the bottom
CGRect tableBounds = self.tableView.bounds;
CGRect pickerFrame = self.datePicker.frame;
pickerFrame = CGRectMake(tableBounds.origin.x,
tableBounds.origin.y + CGRectGetHeight(tableBounds) - CGRectGetHeight(pickerFrame),
tableBounds.size.width,
pickerFrame.size.height);
self.datePicker.frame = pickerFrame;
}
마지막으로 테이블보기가 아래쪽보기 아래에 오지 않게하려면 표보기의 contentInset
을 너의 8 시야.
또한 updateDatePickerBounds
메서드를 viewWillAppear
에서 호출합니다. 내가 왜 그렇게했는지 잊어 버린다.
바닥 글이 바닥에있을 때만 바닥 글이 표시됩니다. 맞습니까? 항상이 시각을 볼 수 있어야합니다. – lnafziger
그레이트 솔루션! 테이블 뷰 섹션 전후에 일반 UIView를 추가 할 수 있습니다. 테이블 뷰 섹션은 기본적으로 다른 뷰와의 통합과 동일하며 실제로 작동합니다. –