tags:

views:

27

answers:

0

hi i am currently working in iphone application in which navigationcontroller is rootview controller. 1) app delegate file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
       UINavigationController *navcon=[[UINavigationController alloc]initWithRootViewController:viewController];
       [window addSubview:navcon.view];
   }

2) After navigating one or more screen my application need TABBarController so aim just added Tabbar controller overviewController thier step may be follows. A) declare tabbar controller inside viewController

@interface UntitledViewController : UIViewController<UITabBarDelegate,UINavigationControllerDelegate> {
    UITabBar *TabBar;
    UIView *currentViewController;
    NSMutableArray *viewControllers;
}
@property (nonatomic, retain) IBOutlet UITabBar *tabBar;
@property (nonatomic, assign) UIViewController *currentView;
@property (nonatomic, retain) NSMutableArray *viewControllers;
- (void)selectTab:(int)tag;
@end
//============= xib files========================
 Drag a tabbar overview and connect it 
//============Implementation file================

#import "UntitledViewController.h"
#import "first.h"
#import "second.h"
#import "third.h"
@implementation UntitledViewController
@synthesize tabBar;
@synthesize currentView;
@synthesize viewControllers;
- (void)viewDidLoad {
    self.navigationController.navigationBarHidden=YES;
    currentViewController.frame=self.navigationController.view.frame;
    viewControllers = [[NSMutableArray alloc] initWithCapacity:3];
    first   *f1=[[first alloc]init];
    second  *f2=[[second alloc]init];
    third   *f3=[[third alloc]init];
    UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:f1];
    UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:f2];
    UINavigationController *nav3=[[UINavigationController alloc]initWithRootViewController:f3];
    [viewControllers addObject:nav1];
    [viewControllers addObject:nav2];
    [viewControllers addObject:nav3];
    [tabBar setSelectedItem:[tabBar.items objectAtIndex:0]];
    [self selectTab:0];
    [super viewDidLoad];
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {  
    [self selectTab:item.tag];
}
- (void)selectTab:(int)tag {
    UIViewController *viewController = [viewControllers objectAtIndex:tag];
    if( viewController == currentView )
    {       return; }
    [self.view insertSubview: viewController.view belowSubview: tabBar];
    if( currentView != nil )
    {       [currentView.view removeFromSuperview]; }
    currentView = viewController;
}
//=============

so application will run perfect navigation also work but every time the viewcontroller inside tabbbar are not RELOADED .ViewController Only Rloading When Tabbar Selected if navigation occure then previous screen changes are not reflected on viewcontroller inside the Tabbar..so out of code where iam wrong plz helps me and give any code snippet. thanks in advance