我通过故事板实现了SWITeveViewController和UITabbarController . 我想在第一个UITabBarItem中显示SWRevealViewController,在其他UITabBarItem中我不想打开完全完成的SWRevealViewController . 但问题是当SWRevealViewController出现时,UITabBar的位置不像viewcontroller那样改变 .
请帮我 .
Storyboard structure
我通过使用 SWRevealViewController 委托方法手动更改 UITabbar 的位置来解决问题 . 将此代码放在 MenuViewController 中 .
SWRevealViewController
UITabbar
MenuViewController
MenuViewController.m
- (void) viewDidLoad { [super viewDidLoad]; UITabBarController *tbc = (UITabBarController *)[[[[UIApplication sharedApplication]delegate]window]rootViewController]; self.tabBar = tbc.tabBar; _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height); self.revealViewController.delegate = self; } - (void) revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position { if (position == FrontViewPositionRight) { _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height); } else { _tabBar.frame = CGRectMake(0, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height); } } - (void)revealController:(SWRevealViewController *)revealController panGestureMovedToLocation:(CGFloat)location progress:(CGFloat)progress overProgress:(CGFloat)overProgress { _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth * progress, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height); }
1 回答
我通过使用
SWRevealViewController
委托方法手动更改UITabbar
的位置来解决问题 . 将此代码放在MenuViewController
中 .MenuViewController.m