Class: UINavigationItem

Inherits:
NSObject show all

Overview

The UINavigationItem class encapsulates information about a navigation item pushed on a UINavigationBar object’s stack. A navigation bar is a control used to navigate hierarchical content. A UINavigationItem specifies what is displayed on the navigation bar when it is the top item and also how it is represented when it is the back item.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (UIBarButtonItem) backBarButtonItem

The bar button item to use when a back button is needed on the navigation bar. When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. When this property is nil, the navigation item uses the value in its title property to create an appropriate back button. If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead. When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.The default value of this property is nil.

Returns:

- (Boolean) hidesBackButton

A Boolean value that determines whether the back button is hidden. When set to YES, the back button is hidden when this navigation item is the top item. This is true regardless of the value in the leftItemsSupplementBackButton property. When set to NO, the back button is shown if it is still present. (It can be replaced by values in either the leftBarButtonItem or leftBarButtonItems properties.) The default value is NO.

Returns:

  • (Boolean)

- (UIBarButtonItem) leftBarButtonItem

A custom bar button item displayed on the left of the navigation bar when the receiver is the top navigation item. In iOS 5.0 and later, the contents of this property always refer to the first bar button item in the leftBarButtonItems array. Assigning a new value to this property replaces the first item in the leftBarButtonItems array with the new value. Setting this property to nil removes the first item in the array. If the bar button item is already in the array, it is moved from its current location to the front of the array. Prior to iOS 5.0, this property contained the single bar item to display on the left side of the navigation bar instead of the back button.

Returns:

- (Array) leftBarButtonItems

An array of custom bar button items to display on the left side of the navigation bar when the receiver is the top navigation item. This array can contain 0 or more bar items to display on the left side of the navigation bar. Items can include fixed-width and flexible-width spaces. If the leftItemsSupplementBackButton property is YES, the items are displayed to the right of the back button, otherwise the items replace the back button and start at the left edge of the bar. Items are displayed left-to-right in the same order as they appear in the array.If there is not enough room to display all of the items in the array, those that would overlap the title view (if present) or the buttons on the right side of the bar are not displayed.The first item in the array can also be set using the leftBarButtonItem property.

Returns:

- (Boolean) leftItemsSupplementBackButton

A Boolean value indicating whether the left items are displayed in addition to the back button. Normally, the presence of custom left bar button items causes the back button to be removed in favor of the custom items. Setting this property to YES causes the items in the leftBarButtonItems or leftBarButtonItem property to be displayed to the right of the back button—that is, they are displayed in addition to, and not instead of, the back button. When set to NO, the items in those properties are displayed instead of the back button. The default value of this property is NO.The value in the hidesBackButton property still determines whether the back button is actually displayed.

Returns:

  • (Boolean)

- (String) prompt

A single line of text displayed at the top of the navigation bar. The default value is nil.

Returns:

- (UIBarButtonItem) rightBarButtonItem

A custom bar button item displayed on the right of the navigation bar when the receiver is the top navigation item. In iOS 5.0 and later, the contents of this property always refer to the first bar button item in the rightBarButtonItems array. Assigning a new value to this property replaces the first item in the rightBarButtonItems array with the new value. Setting this property to nil removes the first item in the array. If the bar button item is already in the array, it is moved from its current location to the front of the array.Prior to iOS 5.0, this property contained the single bar item to display on the right side of the navigation bar.

Returns:

- (Array) rightBarButtonItems

An array of custom bar button items to display on the right side of the navigation bar when the receiver is the top navigation item. This array can contain 0 or more bar button items to display on the right side of the navigation bar. Items are displayed right-to-left in the same order as they appear in the array. Thus, the first item in the array is the rightmost item and other items are added to the left of the previous item.If there is not enough room to display all of the items in the array, those that would overlap the title view (if present) or the buttons on the left side of the bar are not displayed.The first item in the array can also be set using the rightBarButtonItem property.

Returns:

- (String) title

The navigation item’s title displayed in the center of the navigation bar. The default value is nil.When the receiver is on the navigation item stack and is second from the top—in other words, its view controller manages the views that the user would navigate back to—the value in this property is used for the back button on the top-most navigation bar. If the value of this property is nil, the system uses the string “Back” as the text of the back button.

Returns:

- (UIView) titleView

A custom view displayed in the center of the navigation bar when the receiver is the top item. If this property value is nil, the navigation item’s title is displayed in the center of the navigation bar when the receiver is the top item. If you set this property to a custom title, it is displayed instead of the title. This property is ignored if leftBarButtonItem is not nil.Custom views can contain buttons. Use the buttonWithType: method in UIButton class to add buttons to your custom view in the style of the navigation bar. Custom title views are centered on the navigation bar and may be resized to fit.The default value is nil.

Returns:

Instance Method Details

- (Object) initWithTitle(title)

Returns a navigation item initialized with the specified title. This is the designated initializer for this class.

Parameters:

  • title (String)

    The string to set as the navigation item’s title displayed in the center of the navigation bar.

Returns:

- (Object) setHidesBackButton(hidesBackButton, animated:animated)

Sets whether the back button is hidden, optionally animating the transition.

Parameters:

  • hidesBackButton (Boolean)

    Specify YES if the back button should be hidden when this navigation item is the top item. Specify NO if the back button should be visible, assuming it has not been replaced by a custom item.

  • animated (Boolean)

    YES to animate the transition; otherwise, NO.

Returns:

- (Object) setLeftBarButtonItem(item, animated:animated)

Sets the custom bar button item, optionally animating the transition to the new item. If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

Parameters:

  • item (UIBarButtonItem)

    A custom bar item to display on the left side of the navigation bar.

  • animated (Boolean)

    Specify YES to animate the transition to the custom bar item when this item is the top item. Specify NO to set the item immediately without animating the change.

Returns:

- (Object) setLeftBarButtonItems(items, animated:animated)

Sets the left bar button items, optionally animating the transition to the new items. If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

Parameters:

  • items (Array)

    An array of custom bar button items to display on the left side of the navigation bar.

  • animated (Boolean)

    Specify YES to animate the transition to the custom bar items when this item is the top item. Specify NO to set the items immediately without animating the change.

Returns:

- (Object) setRightBarButtonItem(item, animated:animated)

Sets the custom bar button item, optionally animating the transition to the view. If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

Parameters:

  • item (UIBarButtonItem)

    A custom bar item to display on the right of the navigation bar.

  • animated (Boolean)

    Specify YES to animate the transition to the custom bar item when this item is the top item. Specify NO to set the item immediately without animating the change.

Returns:

- (Object) setRightBarButtonItems(items, animated:animated)

Sets the right bar button items, optionally animating the transition to the new items. If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

Parameters:

  • items (Array)

    An array of custom bar button items to display on the right side of the navigation bar.

  • animated (Boolean)

    Specify YES to animate the transition to the custom bar items when this item is the top item. Specify NO to set the items immediately without animating the change.

Returns: