0
我正在创建一个支持所有方向的应用程序。
我在这里使用navigationController。
的方向我使用这个代码带导航后退按钮的自动旋转
- (void)willAnimateRotationToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
category1.frame = CGRectMake(54, 68, 190, 174);
category2.frame = CGRectMake(291, 68, 190, 174);
category3.frame = CGRectMake(525, 68, 190, 174);
category4.frame = CGRectMake(54, 296, 190, 174);
category5.frame = CGRectMake(291, 296, 190, 174);
category6.frame = CGRectMake(525, 296, 190, 174);
category7.frame = CGRectMake(54, 527, 190, 174);
category8.frame = CGRectMake(291, 527, 190, 174);
category9.frame = CGRectMake(525, 527, 190, 174);
category10.frame = CGRectMake(291, 757, 190, 174);
extra1.frame = CGRectMake(80, 781, 138, 125);
extra2.frame = CGRectMake(551, 781, 138, 125);
}
else
{
category1.frame = CGRectMake(61, 50, 190, 174);
category2.frame = CGRectMake(298, 50, 190, 174);
category3.frame = CGRectMake(537, 50, 190, 174);
category4.frame = CGRectMake(774, 50, 190, 174);
category5.frame = CGRectMake(61, 278, 190, 174);
category6.frame = CGRectMake(298, 278, 190, 174);
category7.frame = CGRectMake(537, 278, 190, 174);
category8.frame = CGRectMake(774, 278, 190, 174);
category9.frame = CGRectMake(298, 509, 190, 174);
category10.frame = CGRectMake(537, 509, 190, 174);
extra1.frame = CGRectMake(80, 533, 120, 125);
extra2.frame = CGRectMake(800, 533, 120, 125);
}
}
它完美地在这一观点。当我标签按钮它去secondviewcontroller我显示tableview。
但是,如果我通过导航后退按钮返回第一个视图,则方向不会完美显示。
以上代码不适用于导航后退按钮。
我应该为这个问题做些什么?
任何建议?
预先感谢您。
编辑:
我已删除了我上面的功能从的firstView和代码复制到这个功能。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
category1.frame = CGRectMake(54, 68, 190, 174);
category2.frame = CGRectMake(291, 68, 190, 174);
category3.frame = CGRectMake(525, 68, 190, 174);
category4.frame = CGRectMake(54, 296, 190, 174);
category5.frame = CGRectMake(291, 296, 190, 174);
category6.frame = CGRectMake(525, 296, 190, 174);
category7.frame = CGRectMake(54, 527, 190, 174);
category8.frame = CGRectMake(291, 527, 190, 174);
category9.frame = CGRectMake(525, 527, 190, 174);
category10.frame = CGRectMake(291, 757, 190, 174);
extra1.frame = CGRectMake(80, 781, 138, 125);
extra2.frame = CGRectMake(551, 781, 138, 125);
}
else
{
category1.frame = CGRectMake(61, 50, 190, 174);
category2.frame = CGRectMake(298, 50, 190, 174);
category3.frame = CGRectMake(537, 50, 190, 174);
category4.frame = CGRectMake(774, 50, 190, 174);
category5.frame = CGRectMake(61, 278, 190, 174);
category6.frame = CGRectMake(298, 278, 190, 174);
category7.frame = CGRectMake(537, 278, 190, 174);
category8.frame = CGRectMake(774, 278, 190, 174);
category9.frame = CGRectMake(298, 509, 190, 174);
category10.frame = CGRectMake(537, 509, 190, 174);
extra1.frame = CGRectMake(80, 533, 120, 125);
extra2.frame = CGRectMake(800, 533, 120, 125);
}
return YES;
}
在我的第二个视图控制器
我做
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
当我回去的firstView通过点击导航后退按钮else条件(风景模式)工作正常,但我不知道如果条件为(Portraitmode),为什么它不与一起使用。
确定..我已经尝试过了..但它不工作.. – iUser
那么它应该工作。当你回到这个viewController时,它是对这种方法的回应吗? – mayuur
从此ViewController的nib关闭AutoResize子视图。 – mayuur