Voloda2
Voloda2

Reputation: 12607

Is it possible to add observer or notification when statusBarOrientation changed?

I have a very tricky code, because sometimes I set a new orientation.

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

Is it possible to add observer or notification when statusBarOrientation changed? I want to know what is the current orientation.

Upvotes: 1

Views: 510

Answers (1)

Lorenzo B
Lorenzo B

Reputation: 33428

The code you are using is very very tricky.

The property you are using is declared as the following:

@property (nonatomic, readonly) UIDeviceOrientation orientation

So, your app will get rejected when using this private method.

If you want to change the interface orientation then you should look into the UIViewController callbacks.

About your question you could do it manually. Send a custom notification after setting the new orientation. Then catch that notification wherever you want. But be aware of what I previously said.

For further info you could see this stackoverflow topic on method-uidevice-setorientation-is-it-still-denied.

Hope it helps.

Upvotes: 1

Related Questions