У меня есть UIViewController, у которого есть UIScrollView в пределах которого есть три дочерних UIChildViewControllers в 3 UIContainerViews , каждый UIChildViewController с UITableView . Когда я обновляю высоту UIContainerView (чтобы получить высоту UIScrollView в родительском контроллере) из UIChildViewControllers, все страницы из веб-службы загружаются. Вот код, который приводит к загрузке всех страниц:
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).commentViewHeight.constant = 0 //make the height of one of non visible viewcontroller's containerView to 0
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).burnedPostsHeight.constant = 0
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).userProfileViewHeight.constant = self.tableView.contentSize.height
, когда я удаляю вышеуказанные строки из подкачки кода, работает нормально , , но когда я использую их для обновления ограничения высоты UIContainerView, все страницы из веб-службы загружаются один раз, когда я открываю контроллер . Здесь
полный метод загрузки новой страницы:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if UIApplication.visibleNavigationController.visibleViewController is UserPrfileControl{
if (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).childControllerToUpdate == "userPost"{
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).commentViewHeight.constant = 0
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).burnedPostsHeight.constant = 0
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).userProfileViewHeight.constant = self.tableView.contentSize.height
}
}
if pageNumber >= totalPages {
return
}
else
{
if (listData?.count)! == 10*pageNumber{
if (listData?.count)! - 3 == indexPath.row{
if !boolHitApi{
boolHitApi = true
return
}
pageNumber += 1
if pageNumber >= 2{
if (UIApplication.visibleNavigationController.visibleViewController is UserPrfileControl){
_ = (UIApplication.visibleNavigationController.visibleViewController as! UserPrfileControl).userProfileViewHeight.constant = self.tableView.contentSize.height
}}
self.callService()
}
}
}
}