ios - 以编程方式配置 SWRevealViewController?

标签 ios swift ios8 swrevealviewcontroller

我找到了很多关于如何配置 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/

相关文章:

ios - 异步任务完成时的返回值

swift - 在核心数据实体中使用枚举类型值

ios - 如何使用 Unicode 十六进制值 (UTF-16) 在 Swift 中表达字符串

ios - 我想显示图表并比较它们

ios - 如何在 iOS 中设置文本格式

ios - 如何将 UIView 粘贴到 iOS 7 上的 UIWindow 顶部

ios - Xcode 6 iOS 模拟器不记得应用程序设置

objective-c - 如何使用 enabledRemoteNotificationTypes 更新代码,因为它是 "not supported in iOS 8"?

ios - 将 PDFDocument 作为 NSData 保存到 CoreData(如何将其转换为 NSData?)

ios - Invalid Code Signing Entitlements-in-app-payments 相关