【发布时间】:2013-08-20 12:13:58
【问题描述】:
在我的应用程序中,我使用纵向导航控制器启动 secondviewcontroller,然后在第四个viewcontroller 中完成,我应该在其中旋转 iPhone 以显示图像。 现在的问题是: 如果在目标中我以这种方式设置方向:
我可以使用这个方法来旋转我的图像:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
它工作正常,但我无法锁定属于导航控制器的所有视图,因为它们都可以旋转纵向和横向。
第二个选项是以这种方式设置目标:
但是这个结构没有检测到方向:
会出现在视图中:
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[self willRotateToInterfaceOrientation:orientation duration:1];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else
{
}
}
else{
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else
{
}
}
}
什么是最好的解决方案? 谢谢
【问题讨论】:
标签: ios orientation landscape-portrait