chewy
chewy

Reputation: 8267

shouldAutorotateToInterfaceOrientation from the delegate

in my application I have a background functions which caches data - works fine. I have implemented UIView *cacheProgressView; which is a visual indication to the progress of the caching mechanism. (it contains UIProgressBar and such)

Since I want to show this in all my application views (UINavigation with many views) I have added this to my delegate which take care of it rather well

[self.window addSubview:cacheProgressView];

Problem is: when I rotate the device and since cacheProgressView is attached to the window and not a view I can not set it to a proper position - the following function inside of the delegate is never called:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

    NSLog(@"Rotation detected from the delegate");

    return YES;
}

how should I solve this issue?

Upvotes: 0

Views: 584

Answers (1)

Simon Lee
Simon Lee

Reputation: 22334

You can register for rotation notifications...

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


- (void) didRotate:(NSNotification *)notification{  
  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
  // do stuff
} 

Upvotes: 2

Related Questions