2
votes

In my app i am using tabbar controller with 5 tabs,in 3 tabs,when click on a button it calls one View Controller. I am using same view controller for those 3 tabs so i am getting problem while calling same view in different tabs,So while changing the tab i dont want to call ViewWillAppear method. So what i have do? or else how to find previous selected index of the tabbar controller?

Thanks in Advance

1
it is better to use different view Controller for each tab if u have different ui for each tab either wise use one view controller by changing depending upon self.tabController.selectedIndex - Paresh Navadiya
ya, using like that i have create same view controller with different names right? My app is similar to Facebook,So, when he open same profile in two tab i am getting problem.So i want to find previous tabbar index.@safecase - ganesh manoj
You can use tabBar:didSelectItem: while implementing the UITabBarDelegate: - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item - Paresh Navadiya
ok.from that i can find present index by tabbar.selectedIndex how can find that the selected index has changed? - ganesh manoj

1 Answers

0
votes

I think you are not familiar with iOS Development.

  1. In a TabbarController we can specify as much of UIViewcontroller/UINavigationController object.
  2. if we need to re-use a UIViewcontroller you need to tag the view controller using a property object.
  3. You need to use different instance of UIViewController for different tab.
  4. While Showing a UIViewController its viewWillAppear got fired. we don't able to remove this behavior. But in most case we can handle such case with viewDidLoad (It is called once for an instance of view controller).
  5. if we need to track the previously selected tab item we need to do our own work-around by using a shared class or static variable.

thanks,

Naveen Shan