UINavigationItem has the following private variables
UIKIT_EXTERN_CLASS @interface UINavigationItem : NSObject <NSCoding> {
@private
NSString *_title;
NSString *_backButtonTitle;
UIBarButtonItem *_backBarButtonItem;
NSString *_prompt;
NSInteger _tag;
id _context;
UINavigationBar *_navigationBar;
UIView *_defaultTitleView;
UIView *_titleView;
UIView *_backButtonView;
UIBarButtonItem *_leftBarButtonItem;
UIBarButtonItem *_rightBarButtonItem;
UIView *_customLeftView;
UIView *_customRightView;
BOOL _hidesBackButton;
UIImageView *_frozenTitleView;
}
Is there any way (using KVC,etc.) to read the UINavigationBar *_navigationBar;
I need this to get access to the undefined backButton. which is not in:
@property(nonatomic,retain) UIBarButtonItem *leftBarButtonItem;
@property(nonatomic,retain) UIBarButtonItem *backBarButtonItem;
Don’t do this. It violates the fundamental OOP concept of encapsulation. If Apple decides to rearrange the order or meaning of the ivars in the
UINavigationItemclass, your code may break unpredictably up to and including crashes or man-eating purple dragons.That said, if you’re sure you want to go down this evil evil road, you should be able to reach the
_navigationBarivar with:If that doesn’t work (for instance, if Apple has overridden
+accessInstanceVariablesDirectlyon this class), you can drop down to the Objective-C runtime:Both approaches are incredibly dangerous and run the risk of breaking with any and every point release of the operating system. You have been warned. Here be dragons.