Rajneesh071
Rajneesh071

Reputation: 31091

viewWillTransitionToSize called even if i press power button

While my app is running and i press power button (To lock the device) this function is calling.

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

And returning current state UIApplicationStateActive using

[UIApplication sharedApplication].applicationState

How to prevent calling this function ? or how to ignore if power button is press? because i don't want to perform any action on powerButton press.

Precondition : Launch Screen should be present.

Upvotes: 0

Views: 361

Answers (2)

Rajneesh071
Rajneesh071

Reputation: 31091

This function calling on app minimise and power button press due to new feature of multitasking.
You can make your application full screen to solve this problem.

Check on ✓ Requires full screen

enter image description here

But this is not the proper solution because you have to adopt multitasking in some case.

Upvotes: 1

Eugene Zaychenko
Eugene Zaychenko

Reputation: 319

I investigated this behaviour. It seems this happen only on iPads and maybe it related to split view function.

Try to ignore the code running inside the method by adding at the beginning of the method:

if([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
return;
}

UPDATE:

I found the cause of this issue.

When you press "power" button, the application window changes their size and sometimes it happens before the application sets the correct applicationState:

enter image description here enter image description here

That's why this method calls. Sorry for my english =)

Upvotes: 0

Related Questions