如何在 UINavigationController 的工具栏中(如邮件应用程序)放置进度条?

发布于 2024-08-11 21:39:37 字数 1154 浏览 2 评论 0原文

我的应用程序连接到网络以检索一些数据,我想在我的应用程序的 UINavigationController 的工具栏中显示一个进度栏。

我真正想要的与邮件应用程序非常相似

:              显示示例工具栏布局的邮件应用程序的屏幕截图

除了我希望进度栏左侧没有任何内容,而右侧有一个取消按钮。

我摆弄了代码,试图做到这一点,但我以前从未使用过导航控制器的工具栏,所以我不确定从哪里开始。

有谁知道我可能会这样做,或者我在哪里可以找到解释如何做到这一点的资源?

我已经阅读了 人机界面指南UINavigationController 类参考,以及 视图控制器编程指南,但它们只展示了如何使用简单的按钮和分段控件进行非常基本的工具栏布局。

My application connects to the network to retrieve some data and I'd like to show a progress bar in the toolbar of the UINavigationController of my application.

What I actually want is very similar to the Mail application:

                                      Screenshot of Mail application showing an example toolbar layout

Except I would like to have nothing to the left of the progress bar, and a cancel button on the right.

I've fiddled around with code, trying to do this, but I've never worked with the toolbar of a nav controller before, so I'm unsure of where to start.

Does anyone know I might go about doing this, or where I could find resources explaining how to do this?

I've read over the Human Interface Guide, the UINavigationController class reference, and the View Controller Programming Guide, but they only show how to do very basic toolbar layouts, with simple buttons and segmented controls.

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

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

发布评论

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

评论(2

定格我的天空 2024-08-18 21:39:37

从一个空的 UIView 开始,添加一个文本标签和一个进度指示器,并将它们放置在邮件应用程序中。最后,创建一个包含此视图的 UIBarButtonItem 并将其添加到工具栏:

UIBarButtonItem* progressItem = [[UIBarButtonItem alloc] initWithCustomView:progressItemView];
toolbar.items = [NSArray arrayWithObject:progressItem];

您可以通过编程方式或在 Interface Builder 中执行此操作。

Start with an empty UIView, add a text label and a progress indicator and position them as they appear in the Mail app. Finally, create a UIBarButtonItem that contains this view and add it to your toolbar:

UIBarButtonItem* progressItem = [[UIBarButtonItem alloc] initWithCustomView:progressItemView];
toolbar.items = [NSArray arrayWithObject:progressItem];

You can do this programmatically or in Interface Builder.

路还长,别太狂 2024-08-18 21:39:37

使用 IB 这非常容易。只需将工具栏拖到您的视图中,然后拖动 NSProgressIndicator 即可。最后,将 NSFlexibleSpacer 拖到进度条的左侧,并将取消按钮拖到右侧。您可能需要在左侧和右侧添加一些 NSSpacer 以使所有内容正确排列。

This is quite easy using IB. Just drag in a Toolbar to your view, then drag an NSProgressIndicator. Finally, drag an NSFlexibleSpacer in to the left of the progress bar, and your cancel button to the right. You may need to add a few NSSpacers to the left and right to get everything to line up properly.

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