0

I want to hide an image when the tabBar button is pressed.I have

self.tabBarController.delegate = self;

in my app delegate and the code below is located in my view controller's .m file . but it doesn't work . Can anyone help pls ?

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    if (viewController.tabBarController  == nil)
    {
       img.hidden = YES;
       NSLog(@"Tab Bar Button");
    }
}
visakh7
  • 26,380
  • 8
  • 55
  • 69
Cagatay VASFI
  • 55
  • 1
  • 1
  • 8

2 Answers2

0

Do you know that

In versions of iOS prior to version 3.0, this method is called only when the selected view controller actually changes. In other words, it is not called when the same view controller is selected.

In addition to this, make sure you are hiding the imageView that contains the image.

UPDATE

Get the tabBarController instance in the view controller and make its delegate the view controller. Then you can call this method in the view controller.

visakh7
  • 26,380
  • 8
  • 55
  • 69
  • i have a button which hides the imageView so i'm sure that it's hidden – Cagatay VASFI May 09 '11 at 09:11
  • i did your update but the application didn't start with that and console says 'NSInternalInconsistencyException', reason: 'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.' – Cagatay VASFI May 09 '11 at 09:19
  • http://stackoverflow.com/questions/907857/changing-the-delegate-of-a-tab-bar-exception – visakh7 May 09 '11 at 09:25
  • http://stackoverflow.com/questions/1108782/tab-bar-controller-raising-nsinternalinconsistencyexception – visakh7 May 09 '11 at 09:27
0

give name for the tabbarcontroller and then set the delegate for that.If my suggestion not useful,then ask me freely

Tendulkar
  • 5,550
  • 2
  • 27
  • 53