在我的应用中,我将在主窗口中创建一些UIView
,UIView
使用自动调整大小,但这不是支持
如果设备模式是纵向,那么抱怨工作 但是devicemode是横向登录视图,在减号中获取x位置。
在窗口上添加视图
_window = [UIApplication sharedApplication].keyWindow;
if (!_window) _window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[_window subviews] objectAtIndex:0] addSubview:self.view_login];
图像:
提前感谢..
答案 0 :(得分:1)
_window = [UIApplication sharedApplication].keyWindow;
if (!_window) _window = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIInterfaceOrientation orientation = self.window.rootViewController.interfaceOrientation;
// Set appropriate view frame (it won't be autosized by addSubview:)
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
if (UIInterfaceOrientationIsLandscape(orientation))
{
// Need to flip the X-Y coordinates for landscape
self.view_login.frame = CGRectMake(appFrame.origin.y, appFrame.origin.x, appFrame.size.height, appFrame.size.width+40);
}
else
{
self.view_login.frame = appFrame;
}
[[[_window subviews] objectAtIndex:0] addSubview:self.view_login];
答案 1 :(得分:0)
使用此代码,您尚未设置自动调整遮罩。 试试这个:
[self.view_login setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];