我找到了很多关于如何配置 SWRevealViewController 的教程通过 Storyboard,但我希望完全摆脱 Storyboard和 xibs。
所以我想知道,有没有办法以编程方式配置库?
最佳答案
您下载的 SWReveal 包中有示例项目。如果我没记错的话,它们都是以编程方式实现的。
来自示例项目 #2 的 AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
FrontViewController *frontViewController = [[FrontViewController alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];
SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
mainRevealController.delegate = self;
self.viewController = mainRevealController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
关于ios - 以编程方式配置 SWRevealViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30315889/