我有一个UIWebView,用这种方式填充:
[myWebView loadHTMLString:@"<iframe src=\"http://www.youtube.com/embed/grTCDFbhKMU\" frameborder=\"0\" allowfullscreen></iframe>"
baseURL:nil];
视频已正确启动,但无法切换到横向模式。
我已经在相关的ViewController中写了这个:
- (void)didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[notification object] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft)
{
[self.newsContent setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
}
else if (orientation == UIDeviceOrientationLandscapeRight)
{
[self.newsContent setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
}
else if (orientation == UIDeviceOrientationPortraitUpsideDown)
{
[self.newsContent setTransform:CGAffineTransformMakeRotation(M_PI)];
}
else if (orientation == UIDeviceOrientationPortrait)
{
[self.newsContent setTransform:CGAffineTransformMakeRotation(0.0)];
}
}
可用于更改内容方向,但在视频发布后无用:(
有什么想法吗?
答案 0 :(得分:0)
您应该使用以下方法返回YES:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//All orientations are accepted except for the upsidedown orientation
if(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown) {
return YES;
} else {
return NO;
}
}
如果返回YES,它将旋转,如果没有,则不会旋转。