Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

ios - Visually modifying a UIToolbar from xcode storyboard

I'm using XCode 4 and storyboarding an application I'm creating, however I cannot visually modify the UIToolbar.

I'm attempting to modify a UIToolbar that is inside of a UITableViewController - however I have to place the UIToolbar out of the correct hierarchy in order to be able to modify it visually. I've tried placing it onto the view controller area but that does not make it show up.

At one point I was able to make it appear below, as it's own object however I was not able to recreate that.

Problem

Once I was able to get it to look like this Problem

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your UITableViewController is inside a UINavigationController, which already has its own UIToolbar—you don't need to drag a new one into your view hierarchy. Interface Builder can simulate the toolbar for you under "Simulated Metrics" in the inspector panel.

Once the simulated toolbar is visible, simply drag UIBarButtonItems into it. Use a custom item with a custom view if you need anything more complicated than a button or spacer.

If you need your toolbar items need to be dynamic, you can maintain a reference via IBOutlets without necessarily having them in your view. Then set your UITableViewController's toolbarItems property or call -setToolbarItems:animated: at runtime to display the appropriate items.

See Apple's UINavigationController Class Reference: Displaying a Toolbar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...