I don't no if this is possible, but this there a way to treat a tab bar item click like a regular button click(action)? Here's the reason: I have a tab bar in my application, and for most of the tab bar items, I don't change the screen upon a touch, but I do change the data displayed in the view. It seems that it would be going a bit overboard to use a TabBarAppDelegate for this...is there a better way?
Thanks
Open the Settings app. Scroll down and tap Safari. Scroll down to the Tabs section and locate the option to switch between the Tab Bar and a Single Tab. Select Single Tab to move the Address Bar back to the top of the screen, or select Tab Bar to move it back to the bottom if you change your mind later on.
In the Safari section of the Settings app, you can choose your tab view. The "Tab Bar" option moves the address bar to the bottom of the Safari interface, which is the new design. There is a dedicated control bar at the bottom of the Safari interface, and above that, an integrated tab bar and address bar.
To add a tab, first drag a new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and select view controllers under Relationship Segue . Your tab bar controller will update with a new tab.
The most straightforward way is the UITabBarDelegate. Sorry. Implement your class and inherit the protocol by adding <UITabBarDelegate>
after your class definition e.g.:
@interface MyViewController : UIViewController<UITabBarDelegate>
and then define the method tabBar:didSelectItem:
in that class e.g.
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
// Do Stuff!
// if(item.title == @"First") {...}
}
Then set the delegate on your tabbar like so: myTabBar.delegate = myClassInstance
. The tabBar:didSelectItem:
method can be anywhere including your view controller and is where you will get the event that the button was clicked. More info here:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITabBarDelegate_Protocol/Reference/Reference.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With