use*_*711 45 iphone xcode interface-builder
我正在尝试布置我的xib,以便布局适合iphone 5(4英寸视网膜)和3.5设备.
因为我必须支持IOS-5,所以我不能使用autolayout.我必须使用弹簧和Struts.
我在interface-builder中尝试了一切.但要么我的观点超出了iphone-3.5英寸的底部,要么完全没有填充iphone-4英寸视网膜.
有人可以提示如何让xib与这两种设备兼容吗?
为了更清楚,我添加了截图:
当我在属性检查器中设置大小3.5时:

它看起来在iphone-5.按钮下方有一个空格:

如果我在界面构建器中设置了4英寸的大小.您可以看到底部按钮在iphone-4中不可见.

所以你会问我正在使用的设置是什么.他们是:

Was*_*hah 38
您为UIviewController添加新类别,并在.h文件中添加此代码
- (id)initWithNibNameforIphone4:(NSString *)nibNameOrNil4 NibNameforIphone5:(NSString *)nibNameOrNil5 NibNameforIpad:(NSString *)nibNameOrNilpad bundle:(NSBundle *)nibBundleOrNil;
Run Code Online (Sandbox Code Playgroud)在.m文件中添加此代码
- (id)initWithNibNameforIphone4:(NSString *)nibNameOrNil4 NibNameforIphone5:(NSString *)nibNameOrNil5 NibNameforIpad:(NSString *)nibNameOrNilpad bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super init])
{
self = [self initWithNibName:[self CheckDeviceIphone4:nibNameOrNil4 Iphone5:nibNameOrNil5 Ipad:nibNameOrNilpad] bundle:nibBundleOrNil];
}
return self;
}
-(NSString *)CheckDeviceIphone4:(NSString *)iphone4 Iphone5:(NSString *)iphone5 Ipad:(NSString *)ipad {
return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? ipad :([[UIScreen mainScreen] bounds].size.height == 568) ? iphone5 :iphone4;
}
Run Code Online (Sandbox Code Playgroud)打开YouProject-Prefix.pch文件并在此处导入您的类别
现在你只是在这样的项目中使用它
self.firstView=[[firstView alloc]initWithNibNameforIphone4:@"firstView4" NibNameforIphone5:@"firstView" NibNameforIpad:@"firstViewIpad" bundle:[NSBundle mainBundle]];
Run Code Online (Sandbox Code Playgroud)
谢谢,然后任何问题评论,不要忘记upvote :-)
\
iva*_*oid 20
尝试将此添加到需要支持iPhone 5的所有控制器:
- (void) loadView
{
[super loadView];
self.view.frame = [UIScreen mainScreen].bounds;
}
Run Code Online (Sandbox Code Playgroud)
Nav*_*dse 11
只需使用Interface-builder
将视图大小设置为None 它将在运行时获取视图大小,只需要在视图中处理原点并自动调整每个元素(UILabel,UIImage等).

我今天正在努力解决这个问题,无论我做了什么,我的观点总是显示为320x480,即使在视网膜4"模拟器上运行.甚至[UIScreen mainScreen] .bounds返回320x480!
我发现添加Default-568h@2x.png启动图像是让iOS识别我的应用程序为"视网膜4"准备就绪的关键.一旦我这样做,我发现不得不做任何其他事情来让笔尖自动调整大小没有黑条.不需要两个单独的xib,更改Interface Builder中的设置,覆盖loadView等.
| 归档时间: |
|
| 查看次数: |
51465 次 |
| 最近记录: |