gpt4 book ai didi

ios - iphone sdk 中 subview appdelegate 的自动调整大小问题

转载 作者:行者123 更新时间:2023-11-29 03:03:46 24 4
gpt4 key购买 nike

在我的应用程序中,我将在主窗口中创建一些 UIView 并且 UIView 使用自动调整大小,但这不支持

如果设备模式是纵向然后complatly工作但 devicemode 是横向登录 View ,在负号中获得 x 位置。

在窗口上添加 View

 _window = [UIApplication sharedApplication].keyWindow;
if (!_window) _window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[_window subviews] objectAtIndex:0] addSubview:self.view_login];

图片: my image issue on only landscape mode

提前致谢..

最佳答案

_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];

关于ios - iphone sdk 中 subview appdelegate 的自动调整大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23005335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com