简体   繁体   中英

passing data between views using tabBar

Ok, so I have part of my app that i'm working on passing float variables between views and everything was fine, but with all the button it looked a bit messy. and being so that i am nearly finished I wanted to see if i could add a tabBar to the existing view and clean it up. I found a great tutorial on this and got it to link up and report what tab i was selecting in NSLog so went ahead and pasted the code I had for the button I used to use for the same function. everything went a little funny and i had to make some new variables and i'm down to one last error that I cant figure out. It is calling for an expected expression for the first time i call patternRafter

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSLog(@"didSelectItem: %d", item.tag);

[self activateTab:item.tag];
}

- (void)activateTab:(int)index {
switch (index) {
    case 1:

        patternRafter *patternRafter1 = [[patternRafter  alloc]initWithNibName:nil bundle:nil];

        BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];

        buildNavDelegate.TLPMR = [TLMR text];
        buildNavDelegate.comRaftBirdPassed = [comBird text];
        buildNavDelegate.comRaftLengthPassed = [comRafter text];
        buildNavDelegate.raftThicknessPassed = [rafterWidth text];



        [self presentModalViewController:patternRafter1 animated:YES]; 
        break;
    /*case 2:

        buildersSquare *square1 = [[buildersSquare alloc]initWithNibName:nil bundle:nil];

        BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];

        buildNavDelegate.TLPMR = [TLMR text];
        buildNavDelegate.comRaftBirdPassed = [comBird text];
        buildNavDelegate.comRaftLengthPassed = [comRafter text];
        buildNavDelegate.raftThicknessPassed = [rafterWidth text];



        [self presentModalViewController:square1 animated:YES];         
        break;
    case 3:

        self.tab2ViewController =[[tab2 alloc] initWithNibName:@"tab2" bundle:nil];
        [self.view insertSubview:tab2ViewController.view belowSubview:tabbar1];
        if (currentViewController != nil)
            [currentViewController.view removeFromSuperview];
        currentViewController = tab2ViewController;         
        break;*/
    default:
        break;
}

}

any help would be appreciated. thanks and I just realised I can't post pictures because i'm still a new user. so here is a link if anyone feels like checking it out. http://dl.dropbox.com/u/72193343/Screen%20shot%202012-05-18%20at%209.22.48%20AM.png

I imagine that patternRafter is an instance of a class named PatternRafter? If so, that line needs to look like this:

PatternRafter *patternRafter1 = [[PatternRafter alloc] initWithNibName:nil bundle:nil];

Obj-C is case sensitive and naming conventions call for ivars to begin with lower case and classes to begin with capitals.

- (void)activateTab:(int)index {
switch (index) {
case 1://igot it to work by opening brackets here{

    patternRafter *patternRafter1 = [[patternRafter  alloc]initWithNibName:nil bundle:nil];

    BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];

    buildNavDelegate.TLPMR = [TLMR text];
    buildNavDelegate.comRaftBirdPassed = [comBird text];
    buildNavDelegate.comRaftLengthPassed = [comRafter text];
    buildNavDelegate.raftThicknessPassed = [rafterWidth text];



    [self presentModalViewController:patternRafter1 animated:YES]; //local declaration of 'patternRafter1' hides instance variable
    break;//and closing here} 
case 2:

its working fine but i am receiving warning for -- local declaration of 'patternRafter1' hides instance variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM