Jordi Kroon
Jordi Kroon

Reputation: 2597

Change value storyboard from AppDelegate

I have a imageView in my storyboard. Now I want to set imageView to nil when the app will enter the background (applicationDidEnterBackground and applicationWillTerminate). But I couldn't find a good way to do this.

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    .... imageView.image = nil; ?
}

What is a good way to change a value of imageView from AppDelegate?

Upvotes: 0

Views: 98

Answers (1)

Jordi Kroon
Jordi Kroon

Reputation: 2597

I solved the problem by adding this in viewDidLoad of my viewcontroller.m file:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(removeImage)
                                             name:UIApplicationDidEnterBackgroundNotification
                                           object:nil];

And the removeImage function:

- (void) removeImage {
    ImageView.image = nil;
}

Upvotes: 1

Related Questions