ios - Tab bar without TabBarController - add View Controller for Tab bar item in storyboard -
i have added tab bar (not tabviewcontroller) view controller , added tab bar items tab bar.
now want attach other view controllers tab bar items in storyboard.
when ctrl + drag view controller tab bar item not options.
please suggest way this.
i had same problem, couldn't find way assign viewcontroller own viewcontrollers in tabviewcontroller case.
i solved using containers. 1 contarner each tabbaritem in tabbar, hidden or showed depending of selected tabbaritem in tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item
method.
1. create containers in uiviewcontroller in storyboard: just this select tabbar , ctrl+drag delegate class listen tabbardelegate methods: look here
2. declare corrisponging iboutlets, incliding tabbar:
#import <uikit/uikit.h> @interface tabsmainviewcontroller : uiviewcontroller @property (strong, nonatomic) iboutlet uitabbar *tabbar; @property (strong, nonatomic) iboutlet uiview *directorycontainer; @property (strong, nonatomic) iboutlet uiview *groupscontainer; @end
3. select container show in tabbardelegate method:
-(void)tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item { switch (item.tag) { case 1: _directorycontainer.hidden = no; _groupscontainer.hidden = yes; break; case 2: _directorycontainer.hidden = yes; _groupscontainer.hidden = no; break; default: break; } }
hope helps!
Comments
Post a Comment