my project contains navigation controller and segmented control (with separate view controller: segmentManagingViewController) programmatically and now i added a tab bar in IB..while calling tab bar controller and navigation controller ,segmentManagingViewController view getting loaded twice.. both in tab bar item1 and in first segment i have called segmentManagingViewController view ….
here is screen shot of my app
and following is
application didFinishLaunchingWithOptions method… please do help me out to resolve this …
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
databaseName = @"breadworks.sql";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
[self checkAndCreateDatabase];
[self readBreadsFromDatabase];
[self categoryFromDatabase];
SegmentManagingViewController * segmentManagingViewController = [[SegmentManagingViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:segmentManagingViewController];
[segmentManagingViewController release];
[self.window addSubview:tabBarController.view];
[window addSubview: navigationController.view];
[window makeKeyAndVisible];
return YES;
}
I declared navigation controller and view controllers (which are used as objects of NSArray) in delegate and created initWithNibName Constructor for view controllers( defining Title, Image and other properties of TabBarItems).. here is the updated code chunks ..
following is Definition of initWithNibName in ViewControllers