测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2016年3月 |
由 Michael Kamphausen、cg、Tino Rachui、Mathias Köhnke、Mathias Koehnke、Nico Schümann、Heiko Wichmann、Stephan Lerner、Famara Kassama 维护。
类似于 Facebook 应用程序中的滑动汉堡菜单
APLSlideMenuViewController 应该是,但不必是根视图控制器。它通过 Storyboard 初始化或在您的 AppDelegate 中或通过 APLSlideMenu 子类中的代码初始化。
只需将自定义券如 APLSlideMenuContentSegue
、APLSlideMenuLeftMenuSegue
或 APLSlideMenuRightMenuSegue
从您的 APLSlideMenuViewController 拖到您的内容和菜单视图控制器,并将券标识符命名为 content
、leftMenu
或 rightMenu
。
如果您正在使用异常断点并且您没有使用所有三个券,异常断点将中断执行。为了避免这种情况,您可能希望使用符号断点代替。使用符号 objc_exception_throw
和条件
(BOOL)(!(BOOL)[[(NSException *)$r0 reason] hasSuffix:@"has no segue with identifier 'leftMenu'"] && !(BOOL)[[(NSException *)$r0 reason] hasSuffix:@"has no segue with identifier 'rightMenu'"] && !(BOOL)[[(NSException *)$r0 reason] hasSuffix:@"has no segue with identifier 'content'"])
当在模拟器上测试而不是在设备上时,您需要禁用此符号断点并添加另一个,将条件中的每个 $r0
替换为 $eax
。
导入头文件
#import "APLSlideMenuViewController.h"
初始化示例
id rootViewController = self.window.rootViewController;
if ([rootViewController isKindOfClass:[APLSlideMenuViewController class]]) {
APLSlideMenuViewController *slideViewController = rootViewController;
// first: configure the slide menu
slideViewController.bouncing = YES;
slideViewController.gestureSupport = APLSlideMenuGestureSupportDrag;
// second: set the leftMenuViewController and / or rightMenuViewController
slideViewController.leftMenuViewController = [MyLeftMenuViewController new];
slideViewController.rightMenuViewController = [MyRightMenuViewController new];
// third: set the contentViewController
slideViewController.contentViewController = [MyContentViewController new];
} else {
NSLog(@"Ups, this shouldn't happen");
}
menuViewController
属性重命名为 leftMenuViewController
showMenu:
方法调用重命名为 showLeftMenu:
switchMenu:
方法调用重命名为 switchLeftMenu: