diff --git a/Tusker/Screens/Profile/ProfileViewController.swift b/Tusker/Screens/Profile/ProfileViewController.swift index 58e41b0f..d0f59b4d 100644 --- a/Tusker/Screens/Profile/ProfileViewController.swift +++ b/Tusker/Screens/Profile/ProfileViewController.swift @@ -38,6 +38,8 @@ class ProfileViewController: UIPageViewController { private var headerView: ProfileHeaderView! + private var hasAppeared = false + init(accountID: String?, mastodonController: MastodonController) { self.accountID = accountID self.mastodonController = mastodonController @@ -95,6 +97,12 @@ class ProfileViewController: UIPageViewController { loadAccount() } + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + hasAppeared = true + } + private func loadAccount() { guard let accountID = accountID else { return } if mastodonController.persistentContainer.account(for: accountID) != nil { @@ -122,8 +130,14 @@ class ProfileViewController: UIPageViewController { // Optionally invoke updateUI on headerView because viewDidLoad may not have been called yet headerView?.updateUI(for: accountID) navigationItem.title = account.displayNameWithoutCustomEmoji - pageControllers.forEach { - $0.updateUI(account: account) + + // Only call updateUI on the individual page controllers if the account is loaded after the profile VC has appeared on screen. + // Otherwise, fi the page view controllers do something with the table view before they appear, the table view doesn't load + // its cells until the user begins to scroll. + if hasAppeared { + pageControllers.forEach { + $0.updateUI(account: account) + } } }