My UIViewController
registers for notifications which my model component sends out when it has finished downloading content.
The downloading can occur in the background (by using beginBackgroundTaskWithExpirationHandler:
) so obviously I don't want my GUI to attempt to redraw etc. if the download completes in the background.
So I guess I have two choices - 1) the model knows when its in the background/foreground and doesn't fire the notifications. 2) the UIViewController
deregisters for notifications when its in the background.
Option 2) is preferable.
Is there a method on UIViewController
that is always called when the app goes into the background? Or will the UIViewController
have to register to receive a notification event when the app moves into the background?
(Seems like viewWillDisappear
, viewWillUnload
etc. don't get called when the app moves to the background?)
A UIViewController is an object which manages the view hierarchy of the UIKit application. The UIViewController defines the shared behavior and properties for all types of ViewController that are used in the iOS application. The UIViewController class inherits the UIResponder class. ADVERTISEMENT.
A view controller acts as an intermediary between the views it manages and the data of your app. The methods and properties of the UIViewController class let you manage the visual presentation of your app. When you subclass UIViewController , you add any variables you need to manage your data in your subclass.
A view controller typically manages a single User Interface (UI) or “screen” in your app. It also manages interactions between the UI and the underlying data, better known as models.
make your view controller register for UIApplicationDidEnterBackgroundNotification
in view did load
... the selector method associated will be called before entering background..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With