方向改变从风景到肖像奇怪地工作

时间:2013-03-06 13:32:02

标签: ios objective-c xcode uiviewcontroller uiinterfaceorientation

以横向模式创建应用后。我在纵向视图中添加了我的应用程序的菜单视图 但是当我试图在xib中以编程方式更改视图时   视图已更改,但移动模拟器仍显示为横向视图,同时显示先前的视图背景
我已经解决了很多关于方向的问题,但似乎没有什么对我有用

这是应用的图片参考 enter image description here

并且创建按钮的代码是
简单的按钮代码是

easee = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[easee addTarget:self 
            action:@selector(easy:)
  forControlEvents:UIControlEventTouchUpInside];
[easee setImage:[UIImage imageNamed:@"radioButtonDisabled.png"] forState:UIControlStateNormal];
easee.frame = CGRectMake(85.0, 86.0, 22.0, 22.0);
[self.view addSubview:easee];

1 个答案:

答案 0 :(得分:0)

设备旋转时视图框不旋转。只有框架内的视图边界旋转。 如果您的UIView对象的位置在纵向和横向上不同,并且您已经尝试过struts和spring,这还不够,那么您必须以编程方式对其位置进行编码。在这种情况下,请使用bounds。

easee.bounds = CGRectMake(85.0, 86.0, 22.0, 22.0);

请注意,根据视图中的对象位置,您需要为纵向和横向设置不同的代码(坐标)。

请阅读视图PG:http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html

它会让你很好地理解视图,边界,框架等......

希望这有帮助。

相关问题