From 80b3585b71c7f6b43e5ba9d935079acbe45ab864 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 25 Oct 2020 11:19:37 -0400 Subject: [PATCH] Fix stautses on My Profile not appearing until scroll --- .../Profile/ProfileViewController.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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) + } } }