iPhone 视图无法缩放以适应 iPad 屏幕

发布于 2024-11-06 10:47:02 字数 1000 浏览 0 评论 0原文

我在进度视图覆盖方面遇到了一些麻烦,就像所有事情一样愚蠢。

我创建了一个 UIViewController 的子类,其中的 XIB 具有黑色 50% 不透明背景,中间有一个活动指示器,当我的远程数据类尝试从远程服务器等获取数据时,我可以让它出现和消失 。

它在 iPhone 上运行良好,可以缩放和旋转

然而,当我在 iPad 模拟器或设备上启动它时,正方形仅填充屏幕的左上角,并且不会调整大小以适应显示屏。

但是,我的所有其他视图都是以相同的方式创建的,包括它将位于的所有表视图。

我的应用程序使用一个单元格初始化一个表格视图,其中显示“正在加载...”,然后调用远程数据服务类,该类然后执行以下操作:

progress = [[ProgressActivityViewController alloc] initWithNibName:@"ProgressActivityViewController" bundle:nil];
UIViewController *dlg = (UIViewController *)self.delegate;
[dlg.view addSubview:progress.view];

注意:进度在 .h 文件中设置为 ProgressActivityViewController) 这是添加和删除子视图的远程数据服务类,当您初始化 RemoteData 类时,您将其“self”作为委托传递,以便它可以通过协议与其进行通信。

我知道这需要使用“isKindOfClass”等进行一些其他类型检查,我可以稍后添加,但我需要将简单的视图拉伸到全屏。

这段代码确实有效,并将视图显示在屏幕上,但它只是没有填满 iPad 上的屏幕

我使用的活动指示器示例的来源位于此链接: http://tapadoo.com/2009/iphone-如何进行全屏活动状态/

I'm having a bit of trouble with, as silly as all things, a progress view overlay.

I've created a subclass of UIViewController with a XIB with a black 50% opaque background and an activity indicator in the middle of it, I can get it to appeaer and disappear when my remote data class tries to get data from the remote server etc.

It works fine on the iPhone, scales and rotates.

However, when I fire it up in iPad simulator or on device, the square only fills the upper left corner of the screen and won't resize to to fit the display.

But, all my other views are created in the same way, including all the tableview's that this will sit over.

My app initialises a table view with a single cell that says "Loading..." and then calls the remote data services class which then does the following:

progress = [[ProgressActivityViewController alloc] initWithNibName:@"ProgressActivityViewController" bundle:nil];
UIViewController *dlg = (UIViewController *)self.delegate;
[dlg.view addSubview:progress.view];

NB: progress is set up in the .h file as ProgressActivityViewController)
It's the remote data services class that is adding and removing the subview, when you init the RemoteData class, you pass it 'self' as the delegate so it can talk to it through a protocol.

I know this needs some other type checking with 'isKindOfClass' etc which I can add in later but I need to get the simple view to stretch to full screen.

This code does work and puts the view on the screen but it just doesn't fill the screen on the iPad

The source for the activity indicator example i've used is at this link:
http://tapadoo.com/2009/iphone-how-to-do-full-screen-activity-status/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶视觉 2024-11-13 10:47:02

您的项目中是否有 iPad 范例 .xib,并且还在应用程序的 plist 中列出了该 iPad xib 文件?如果没有,您可能只会在左上角看到一个窗口。

创建一个新的通用 iPhone/iPad 项目,模板将显示您在 plist 中的何处提及 iPad xib。

Do you have an iPad paradigm .xib in your project, and also listed that iPad xib file in your app's plist? If not, you may only get a window in the top left corner.

Create a new Universal iPhone/iPad project, and the template will show you where to mention the iPad xib in the plist.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文