IOS Rotation Notification does not work - ios

I'm trying NSNotificationCenter with this code:
but does not print anything, never enters in the rotate function, any ideas? thanks a lot

Did you confirm that you've enabled the appropriate orientations under App General settings?

Related

iOS 15 focus mode development

We can set up a focus status with customized turning on time and turning off time. I'd like to be notified when I am in my own app. Unfortunately INShareFocusStatusIntentHandling was not called when a system notification "Focus on" came out. Anybody know some solutions or ideas about it. Thanks ahead!
According to https://developer.apple.com/forums/thread/682143 you need to implement an Intents Extension from your app and have that extension share the results to the main app via UserDefaults or some other method. You cannot observe the focus state changes directly in your app.

Is there any way to disable or detect screen recording in movie playing view for iOS application?

Can you suggest any idea to prevent screen recording as user make copy of my content by screen recording.
Thank you!
The UIScreen.isCaptured property is the recommended way of doing this by Apple. See the following article:
https://developer.apple.com/library/content/qa/qa1970/_index.html#//apple_ref/doc/uid/DTS40017687
I don't think so Its possible because still apple officially does not announce that we can do like that but as I know that in iOS 11 UIScreen has new property isCaptured
True if this screen is being captured.
You can do something by use of it. But not sure that you can prevent screen recording.
Second below question might be helpful for you.
Prevent screen capture in an iOS app

Using UIDeviceOrientation change notification instead of viewillTransistionToSize

I have managed to support Portrait and Landscape orientations for my app.
However, my implementation is based on UIDeviceOrientationChangeNotification. I do not use viewillTransistionToSize
Offical Apple sample code for AlternateViews does use notification based approach. So I assumed it should be fine.
Is there any significant advantage/disadvantage of using one over another?
Would it ever happen that my app will not get deviceOrientationChangenotification?
Please clarify.
I am using a combination of both. But to me it looks like viewillTransistionToSize gives more control as you can execute code
before rotation begins
during rotation
after rotation
while in case of Notification you only execute code after rotation.
Not sure but I found this thru experimentation and not thru docs.

iOS local notification only when the screen is locked and without screen activation ?

Got 2 questions for the xcode experts :
- I would like to send a (repeating) local notification only to the locked screen but without having the screen turning on, it is possible ?
- I also would like to check whether the screen is on or off (for this very purpose) : is there any way with the current IOS version (IOS 7) ?
Many thanks for any help !
No this is not possible, frits it will be very hard to get you app running in background without misusing one of the background modes.
You cannot detect if the devices is locked and you will flood the notification center with messages.
If you do manage to get it working then there is good chance that Appel will reject your app for doing this.
You can check the screen by checking the applicationState property, which will be set to UIApplicationStateInactive when the phone is set to lock/sleep (as opposed to UIApplicationStateBackground).
As for the notification, you can set a push notification delegate (I've not done it from scratch, but I did it using Urban Airship and creating my own custom push handler class) and handle whether to post an alert or not there. I'm not sure, though, whether having the phone sleep will kick notifications to the OS level, which would default to showing a notification on the screen.

Can I disable autorotation animations and still get rotation notifications?

I want to implement all my own rotation animations but if I only return YES to UIInterfaceOrientationPortrait in shouldAutorotateToInterfaceOrientation:, I no longer get didRotateFromInterfaceOrientation: and willRotateFromInterfaceOrientation: notifications.
Can I get notifications for rotations while also disabling the default rotation animations?
You should still be able to subscribe to UIDeviceOrientationDidChangeNotification even if you've disabled view controller autorotation via shouldAutorotateToInterfaceOrientation:.
I know this question is a bit old, but just thought I'd add a link to a tutorial I found when I was in the same situation you were (wanting to get notifications for device rotation without allowing views to rotate).
This tutorial gives a nice and simple overview of how to handle device rotation using UIDeviceOrientationDidChangeNotification.

Resources