Iphone 加载后旋转视图
在我的一个应用程序中,我实现了一个可以播放电影的视图。这景色的起源是肖像画。我覆盖了foloowing方法,以便在播放电影时视图将旋转Iphone 加载后旋转视图,iphone,cocoa-touch,rotation,Iphone,Cocoa Touch,Rotation,在我的一个应用程序中,我实现了一个可以播放电影的视图。这景色的起源是肖像画。我覆盖了foloowing方法,以便在播放电影时视图将旋转 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (isPlayingMovie) { return (interfaceOrientation == UIInterfaceOrientationL
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (isPlayingMovie) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft );
} else {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
问题是视图不会自动旋转。我认为视图只有在加载时才在视图控制器中调用此方法,但我如何才能强制他再次调用它
提前感谢。尝试使用此方法中的代码
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration{
//required functionality
}
干杯尝试使用此方法中的代码
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration{
//required functionality
}
干杯简短回答:不可能 长句回答:只需返回仅进行纵向绘制并自行旋转视图即可 获取旋转通知(将其放在ViewDidDisplay或其他位置): 然后在“rotationChange:”中进行旋转(此处的webview示例): 编辑:如果您不需要通知,请不要忘记禁用通知(如“ViewDidEnglishe:”)
简单回答:不可能 长句回答:只需返回仅进行纵向绘制并自行旋转视图即可 获取旋转通知(将其放在ViewDidDisplay或其他位置): 然后在“rotationChange:”中进行旋转(此处的webview示例): 编辑:如果您不需要通知,请不要忘记禁用通知(如“ViewDidEnglishe:”)
- (void)rotationChange:(NSNotification *)notification {
UIDeviceOrientation o = [[UIDevice currentDevice] orientation];
CGFloat rotation;
[self.webView setTransform:CGAffineTransformIdentity];
switch (o) {
case UIDeviceOrientationPortrait:
rotation = 0;
case UIDeviceOrientationPortraitUpsideDown:
rotation = 180;
...
}
[[UIApplication sharedApplication] setStatusBarOrientation:o animated:YES];
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformRotate(transform, rotation * (M_PI / 180.0f));
[self.webView setTransform:transform];
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];