I currently have a tab app for iPhone with multiple view managers. All views are developed in Interface Builder. I would like to get the currently selected pointer in the control panel of the viewcontroller, but for some reason this property returns (null).
I called the following in the viewDidLoad function of my view manager:
self.tabBarController.selectedIndex
What would be the right way to do this?
Updated with class code AppDelegate.
Myappppelegate.h
#import <UIKit/UIKit.h>
@interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
MyAppDelegate.m:
#import "MyAppDelegate.h"
@implementation MyAppDelegate
@synthesize window, tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:tabBarController.view];
}
- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}
@end
source
share