UIWebView autorotation weird behavior
I managed to show a UIWebView that shows content from the internet. But apparently it does not rotate as it should: http://www.youtube.com/watch?v=VV0BmNkSrvU
I'm using this code:
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
_webView = [[UIWebView alloc] initWithFrame:rect];
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
NSURL* url = [[NSURL alloc] initWithString:URL]; NSURLRequest* request = [[NSURLRequest alloc] initWithURL:url];
[_webView loadRequest:request];
//Unity's UIView
UIView* subView = [window.subviews objectAtIndex:0];
[url release];
[开发者_StackOverflow中文版subView addSubview:_webView];
It seems that this code has not been placed inside a UIViewController. Autorotation works correctly only inside a UIViewController. If you want to manage it outside a UIViewController you must observe all orientation change notifications and then transform your view accordingly.
精彩评论