I have a UIViewTable with navigation bar. When I read data I display UIViewController with ActivityIndicator on top of the table. The problem is when I rotate device this top view is not rotating, I don't know why? :( This is how I add top view with ActivityIndicator:
UIView *view = [[UIApplication sharedApplication] keyWindow];
[view addSubview:viewWithLoader.view];
开发者_开发知识库
This is how I remove it:
[viewWithLoader.view removeFromSuperview];
This is method from top view (with ActivityIndicator):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
after you call [self.window makeKeyAndVisible]; on your App delegate, the views that get the rotation notification, animation, etc, etc. are the subviews of that initial view.
It happen to me that I had a top bar that replaced the status bar. so I thought it will be a good idea to actually add it as a sub view of the key window. But that being the case resulted in the outcome you are experiencing.
You have 2 options
whoever owns that topview should take care of rotating it or remove/add it when a rotation occurs so it has the right orientation.
make that topview a subview of one of the views that ARE autorotating.
Both are really easy to implement but I found no. 2 is more visually attractive for the user.
I found solution :) I add this top view (with loader) as 'modal view' and rotation works fine in all views :)
...
[self presentModalViewController:ldr animated:YES];
...
[self dismissModalViewControllerAnimated:YES];
精彩评论