Custom UIView does not rotate when device orientation changes

I created a UIView on which there are two controls, a label and an activity indicator (spinning wheel) to display when the device is synchronized. Since this UIViewController should be accessible globally, I add it to the FinishedLaunching application:

window.AddSubview (navigationController.View); window.AddSubview (SyncSpinner.View); window.MakeKeyAndVisible ();

I override the shouldAutoRotate event and return true to allow the rotation of the view using the device. However, I was not able to make this point of view rotate. I even tried calling the shouldAutoRotate event from the navigationController shouldAutoRotate event, but it still doesn't spin.

How to create a very simple view to use as a status dialog box with a label at the top, scrolling in the middle and correct rotation?

Thank.

+3
source share
2 answers

A similar thing happened to me. I don’t know why, but the iPhone sends autorotation messages only to the new controller of the added form.

Rotate to generate notifications and send them to the controller. Use this block of code in a ready-made way to run:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: viewController selector:@selector(changeOrientation:) name:UIDeviceOrientationDidChangeNotification object:nil];
+1
source

, TweetStation , UIViewController. UIViewController , .

TweetStation , :

http://github.com/migueldeicaza/TweetStation/blob/master/TweetStation/Main.cs#L409

+1

Source: https://habr.com/ru/post/1755199/


All Articles