开发者

Set UIView Title from Interface Builder

开发者 https://www.devze.com 2023-04-03 06:28 出处:网络
I have an XCode project for the iPhone. The UI Hierarchy looks like this: MainWindow UINavigationController

I have an XCode project for the iPhone. The UI Hierarchy looks like this:

  • MainWindow
    • UINavigationController
      • 开发者_如何学Go
      • RootView (derives from UIView)
      • NestedView1 (derives from UIView)
      • NestedView2 (derives from UIView)

This should be a typical setup for many projects. The app starts from RootView and as a result of some user action the RootView changes to NestedView1, then back to RootView, then to NestedView2.

Is there any way to set the title displayed in the Navigation Bar from within Interface Builder, as opposed to calling [self setTitle: @"Nested View X"]; from the code of each View Controller? What I'd like to have is opening a XIB of each of the View Controllers, selecting something visually and setting the title in the Inspector. Is this possible somehow?

Or maybe there is another approach not to have strings in the code for better localization?


Apple have many resources available on how to localise your apps, there is a directory of them here.

In particular, read this bit about localising strings.


click on the RootView in the interface builder you will find a navigation item component in the RootView, click on that component and you will find in the "Attribute Inspector" window a title field, write there the title that you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消