UIView被添加了翻转

时间:2014-07-09 13:56:06

标签: ios objective-c ipad uiview

我创建了一个空的* .xib,添加了类并引用它们。

我需要显示当前显示的所有UIViews的控件。我这样做是为了显示控件:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
ExternalDisplayRemoteControl *remoteControl = [[ExternalDisplayRemoteControl alloc]initWithNibName:@"ExternalDisplayRemoteControl" bundle:nil];
remoteControl.view.frame = CGRectMake(20, 20, appDelegate.window.bounds.size.width-40, appDelegate.window.bounds.size.height-40);
remoteControl.view.alpha = 0.0;

[appDelegate.window addSubview:remoteControl.view];



//Display the customView with animation

[UIView animateWithDuration:0.4 animations:^{
   [remoteControl.view setAlpha:1.0];
} completion:^(BOOL finished) {}];

在Interface Builder中,我试图将方向设置为横向 - 没有帮助

结果是:

我添加的UIView顺时针旋转了90度......为什么?

截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

找到答案:

此解决方案:不尊重设备轮换。

更好的解决方案:

UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window)
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[window subviews] objectAtIndex:0] addSubview:remoteControl.view];