English 中文(简体)
How can I put a progress bar in a UINavigationController s toolbar like the Mail app?
原标题:

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.

最佳回答

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.

问题回答

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.





相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签