如何在界面生成器中使用与4英寸iPhone兼容的uitableview [英] How to make a uitableview in interface builder compatible with a 4 inch iPhone

查看:108
本文介绍了如何在界面生成器中使用与4英寸iPhone兼容的uitableview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在界面制作工具中使用4英寸iphone5和旧版iPhone 4 / 4s进行uitableview?

How do I make a uitableview in interface builder compatible with 4 inch iphone5, and the older iPhone 4/4s?

Xcode 4.5中有三个选项:

There are three options in Xcode 4.5:


  • Freeform

  • Retina 3.5全屏

  • Retina 4全屏

如果我选择了Retina 4,那么在3.5英寸手机中它会越过/溢出屏幕边框

If I chose Retina 4, then in the 3.5 inch phone it crosses/overflows the screen border

使用代码,我可以相应地设置框架,但是使用界面构建器有什么用?

Using code, I can set the frame accordingly, but then what is the use of using interface builder?

如何做到这一点使用Interface Builder?

How should one do it using Interface Builder?

编辑

我的问题是iphone 5 retina 4英寸屏幕。
当检查具有状态栏和导航栏的视图的大小时,这里是self.view.frame.size.height / width的值,如果我选择自由形式/无/视网膜,则为320.000000 x 416.000000 3.5

My question is for iphone 5 retina 4 inch screen. When inspecting the size of the view which has a status bar and navigation bar, here is the value of self.view.frame.size.height/width, frame 320.000000 x 416.000000 in case I choose freeform/none/retina 3.5

设置自动调整大小选项,以便视图在所有方向上扩展,即所有支柱和弹簧都已启用。

The autoresizing options are set so that the view expands in all directions, that is all struts and springs are enabled.

编辑
在iOS6模拟器中进行测试,如果我在代码中设置以下内容

EDIT For testing in iOS6 simulator, If I set the following in code

self.tableView.frame    = CGRectMake(0, 0, 320, 546);
self.tableView.bounds   = CGRectMake(0, 0, 320, 546);
self.view.frame         = CGRectMake(0, 0, 320, 546);
self.view.bounds        = CGRectMake(0, 0, 320, 546);
NSLog(@"%2f - %2f", self.view.bounds.size.width, self.view.bounds.size.height);
NSLog(@"%2f - %2f", self.tableView.bounds.size.width, self.tableView.bounds.size.height);

我得到以下输出

 320.000000 - 546.000000
 320.000000 - 546.000000

所有从顶部低于480像素的行是不可选择的,因为'视图'仍然认为它们超出范围。

And All the rows below the 480 px from the top are not selectable, as the 'view' still thinks they are out of bounds.

我的解决方案

为所有屏幕设置Retina 4的大小,甚至是主窗口xib文件。在此之后,它甚至可以在iphone 4上正常工作。所有480px以下的行现在都可以在iOS 6模拟器中点击

Set the size to Retina 4 for all screens, even the main window xib file. It seems to work fine even on the iphone 4 after this. And all rows below 480px are now clickable in iOS 6 simulator

推荐答案

提示设置尺寸属性如果您在应用程序中显示操作表,请选择Retina 4 Full Screen。此解决方案实际上将主窗口的尺寸设置为iPhone 5的尺寸。在我的情况下,当您尝试显示操作表时,在iPhone 4中设置此受影响的显示,因为它将尝试从可视屏幕下方显示它。

BEWARE of setting the size attribute to "Retina 4 Full Screen" if you present actionsheets in your application. This solution actually sets the dimensions of the main Window to the dimensions of the iPhone 5. In my case, setting this affected display in the iPhone 4 when you try to show an action sheet because it will try to show it from below the viewable screen.

适用于所有情况的正确解决方案是将大小设置为none并在app delegate didfinishloading方法中检测屏幕大小并将主窗口设置为该大小或设置rootviewcontroller对该大小的视图。操作表将正常工作。

The proper solution that works for all cases is to set the size to none and detect the screensize in the app delegate didfinishloading method and set the main window to that size or set the rootviewcontroller's view to that size. Actionsheets will work correctly.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);

}

这篇关于如何在界面生成器中使用与4英寸iPhone兼容的uitableview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆