doc92606
doc92606

Reputation: 701

TableViewController Delegate not getting Called

So here's what I want happening. I have many tab bar items, and I have one particular item that says "share". When the user taps it, a share screen should pop up instead of me clicking on the item and seeing what's on that item's page.

To make it simple, I want an action to be called when I hit the tab bar icon. So I looked this up and found this delegate:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

Within this delegate I want something to happen, like, NSLog(@"Something") But this delegate never gets called. I've set the delegate in the .h and I've put this code in my TableViewController .m and my DisplayViewController.m

Both .h's have the delegate set. I don't know why it's not being called but I'll put my code here for interpretation anyway.

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if(item.tag == 5)
    {

   NSLog(@"Something");

    }
}

and in my .h:

@interface PhotosTableViewController : UITableViewController <UITabBarControllerDelegate, UITabBarDelegate>

Upvotes: 0

Views: 167

Answers (1)

Shamsudheen TK
Shamsudheen TK

Reputation: 31339

Both .h's have the delegate set.

call yourTabBar.delegate = self;

in your TableViewController .m or DisplayViewController.m viewDidLoad method.

Upvotes: 1

Related Questions