Rahul Vyas
Rahul Vyas

Reputation: 28720

can we check applicationwillresignActive in iphone simulator?

- (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"resigning active status...");
}

i have tried hardware-lock in iphone simulator but this isn't called. I do want to call it in another UIviewcontroller class not in the appdelegate itself.I also added in the viewController's header File.

Upvotes: 2

Views: 1333

Answers (2)

Jack
Jack

Reputation: 3878

According to the documentation, the "applicationWillResignActive" method will get called if the device is locked.

As such pressing Command-L (or "Hardware" >> "Lock"" in the menu) will cause the iPhone simulator to lock and hopefully trigger this method.

Upvotes: 3

Tom Irving
Tom Irving

Reputation: 10059

I could only get this code to work in the AppDelegate file as well.

You could trying adding your view controller as an observer using the NSNotificationCenter,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foo) name:@"AppResigned" object:nil];

Then in the applicationWillResign post the notification,

[[NSNotificationCenter defaultCenter] postNotificationName:@"AppResigned" object:nil];

Hope that helps!

Upvotes: 2

Related Questions