سؤال

I want to add the view of a UIViewController as a subview. But self.view is having a UITabBarController. I want to display the subview above tabbar. So that tab bar hides behind subview. Please suggest some idea.

هل كانت مفيدة؟

المحلول

Try this, if you want to hide/show the UITabBarController of view:

For hide the tabbar:

 - (void)hideTabBar:(UITabBarController *) tabbarcontroller
 {
     for(UIView *view in tabbarcontroller.view.subviews)
     {
        if([view isKindOfClass:[UITabBar class]])
       {
           [view setFrame:CGRectMake(view.frame.origin.x, (isiPhone5?568:480), view.frame.size.width, view.frame.size.height)];
        }
        else
        {
           [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, isiPhone5?568: 480)];
        }
     }
  }

for show Tabbar:

   - (void)showTabBar:(UITabBarController *) tabbarcontroller
     {

         for(UIView *view in tabbarcontroller.view.subviews)
         {
            if([view isKindOfClass:[UITabBar class]])
            {
               [view setFrame:CGRectMake(view.frame.origin.x,  (isiPhone5?519:431), view.frame.size.width, view.frame.size.height)];
            }
            else
            {
               [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width,  isiPhone5?519:431)];
            }
         }
      }

may be it will help.

نصائح أخرى

Where you alloc and initialize TabBar, write this line

objectOfTabbar.hidden=YES; 

Then give the frame of your subview same as of TabBarController. This way your tabbar will be hidden and view will be shown .

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top