Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-25-2011, 04:09 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 14
appdevelop is on a distinguished road
Default Move from navigationcontroller to tabbarcontroller and to other views of tabbarcontro

Hi, I have a UITableViewController, and double clicking on the table cells I am loading a custom tabbar controller. All my tabbar items will have hierarchy of views. My problem is that I am not able to push, on the custom tabbar items another uiview. I get self.navigationcontroller as null in my custom tabbarviewcontroller although I am able to get the proper value of self.navigationcontroller in my UITableViewController. Also I am able to view the navigationbar title on my tabbaritem view, but then why am I not able to push another view on that? Can anybody please help me out, below is my code.

MyTableViewController(this is the controller where I can get the value self.navigationcontroller),

Code:
- (void)viewDidLoad {

  //Initializing Custom Tabbar controller that has 2 other tabbar views

    UITransTabViewController *transtvController = [[UITransTabViewController alloc] initWithNibName:@"TransTabViewController" bundle:nil];

    self.transtabViewController = transtvController;    

    [transtvController release];
}

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


    NSUInteger row = [indexPath row];

    //This does push the custom tabbar controller onto the UITableViewController

    if(row==0){
        [self.navigationController pushViewController:self.transtabViewController animated:YES];
    }   
}
UITransTabViewController code(this is my custom tabbar controller),

Code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {

        // Custom initialization of my two tab items on the tabbar controller
        ArrivalsTabViewController *arrTabViewController = [[ArrivalsTabViewController alloc] initWithNibName:@"Arrivals" bundle:nil];

        DeparturesTabViewController *depTabViewController = [[DeparturesTabViewController alloc] initWithNibName:@"Departures" bundle:nil];


        NSArray *array = [[NSArray alloc] initWithObjects:arrTabViewController, depTabViewController, nil];
        self.viewControllers = array;

        [self.view addSubview:arrTabViewController.view];
        self.selectedViewController = depTabViewController;

        [array release];
        [arrTabViewController release];
        [depTabViewController release];

    }
    return self;
}


- (void)viewDidLoad {
    NSLog(@"MY NAV CONTROLLER IN TRANSTABVIEWCONTROLLER IS = %@", self.navigationController);

    if (self.navigationController == nil) 
        NSLog(@"navigation is nil");
    if (self.parentViewController.navigationController == nil)
        NSLog(@"parent navigation is nil"); 

        //here i get both navigation and parent navigation as nil..

    tabBar.selectedItem = arrivalsTabBarItem;   
    [super viewDidLoad];
}



- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if (item == arrivalsTabBarItem) {

        UIViewController *arrViewController = [viewControllers objectAtIndex:0];
        [self.selectedViewController.view removeFromSuperview];
        [self.view addSubview:arrViewController.view];
        self.selectedViewController = arrViewController;        

    } else if (item == departuresTabBarItem) {
        UIViewController *depViewController = [viewControllers objectAtIndex:1];
        [self.selectedViewController.view removeFromSuperview];
        [self.view addSubview:depViewController.view];
        self.selectedViewController = depViewController;
    }
}
I have a button in my ArrivalsTabViewController which is the first tab item in my custom controller,

Code:
- (IBAction)findArrivals:(id)sender {   

    MyViewController *myController=
    [[MyViewController alloc]initWithNibName:@"MyView" bundle:[NSBundle mainBundle]];
    self.hidesBottomBarWhenPushed = YES;    


    [self.navigationController pushViewController:myController animated:YES]; 
    [myController release];

}
On click of the button, I am not able to push myController on the tabbar item view. Please let me know if I have not made my self clear enough.
appdevelop is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone sdk 4.2, uinavigationcontroller, uitabbarcontoller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 348
6 members and 342 guests
doffing81, dre, iOS.Lover, jenniead38, Kirkout, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0