Closed surayashivji closed 7 years ago
Hey @surayashivji good question. When ViewController is instantiated ViewDidLoad method is called. Check FeedVC. I'm calling fetchItemsList method to download items. You can call the method to download data here. Same is true for ViewDidAppear. After selecting tab ViewControllers appears and starts to download images. However relying on ViewDidAppear method is not a good idea since we are instantiating ViewControllers programmatically. I will suggest you to call method to load data once viewControllers are instantiated and added to collectionview. Check "MainViewController" line 85.
P.S. Don't hesitate to ask any questions. Will be happy to answer 😊
Hi! Thanks for the great information.
If I need to load more data every time the tab is selected (ie load more posts from the database, or change the content depending on what table view row was selected), how should I go about loading the data?
Thank you!!
it that case you should keep strong pointer to that viewController and directly call a method. Like this way.
var vc: MainViewController()
override viewDidLoad{ super.viewDidLoad() let viewController = self.storyboard?. instantiateViewController(withIdentifier: "name") as! MainViewController // you should point to this vc self.vc = viewController }
//later if you want to call a method to get data
MainViewController.fetchData()
// where fetchData is a method in that ViewController to download something
Hi aslanyanhaik! I apologize for my late follow up-- happy new year!
I tried keeping the strong pointer to my ProfileViewController (the view controller I'm trying to load data in each time its tab is selected), but haven't been able to get it working.
I'm trying to load new data each time the last tab, ProfileViewControler.swift
, is selected.
For reference, I'm working on this project: https://github.com/surayashivji/PotterPics
Any idea how to integrate this implementation?
All of your help is much appreciated! :)
Happy new year :) Let me check the source code
Hey Suraya, seems I can't run the app. Do you want to do a screencast? So we can together go through all issues
Oh how odd-- what's the error that you're getting? Sure that'd be awesome!
there are some APIs deprecated in iOS 10, and also can't login with Facebook
my skype id: aslanyanhaik
Hello! Thanks for the fantastic app.
I have a question about the way the application lifecycle works for the tabs.
When a new tab is clicked, are any of the lifecycle methods invoked (viewDidAppear, viewWillAppear, viewWillLoad)? I know they are invoked when the app is first run, but I'm trying to load new data before a tab is selected (ie in viewWillAppear or viewDidLoad), but none of the methods are running when I select a tab.
Thank you!