我尝试在 Objective-c中添加SlideMenuControllerSwift 。
我可以在我的 AppDelegate.m中访问[slideMenuController openLeft]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *main = [sb instantiateViewControllerWithIdentifier:@"ViewController"];
LeftViewController *left = [sb instantiateViewControllerWithIdentifier:@"LeftViewController"];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:main];
left.mainViewController = nvc;
SlideMenuController *slideMenuController = [[SlideMenuController alloc] init];
slideMenuController = [slideMenuController initWithMainViewController:nvc leftMenuViewController:left];
[slideMenuController openLeft]; // appears with open menu
self.window.rootViewController = slideMenuController;
[self.window makeKeyAndVisible];
return YES;
}
SlideMenuControllerSwift具有UIViewController 扩展。
extension UIViewController {
....
public func toggleLeft() {
slideMenuController()?.toggleLeft()
}
但是如何在 obj-c ViewController.m 中访问 toggleLeft() ?