iOS将PKRevealController与Storyboard&自动布局 [英] iOS Integrate PKRevealController with Storyboard & Auto Layout

查看:90
本文介绍了iOS将PKRevealController与Storyboard&自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将PKRevealController集成到我的现有项目中。

I'm trying to integrate PKRevealController into an existing project of mine.

https://github.com/pkluz/PKRevealController

如果我正在使用故事板,如何设置我的左视图控制器,右视图控制器和前视图控制器?自述文件说要做...

How do I set up my left view controller, right view controller, and front view controller if I'm using storyboard? The readme says to do...

PKRevealController *revealController = [PKRevealController revealControllerWithFrontViewController:frontVC leftViewController:leftVC options:options];

self.window.rootViewController = revealController;

我会在现有的故事板项目中放置这些代码行?或者有没有其他选择来设置它?

Where would I put these lines of code in my existing storyboard project? Or are there any alternatives to set this up?

谢谢!

推荐答案

我知道这是一个老线程,但我还是会在这里解决它:)

I know this is an old thread, but I'm gonna out it here anyways :)

使 PKRevealController 基本上与storyboard一起工作你需要三个视图控制器。

To make PKRevealController work with storyboard basically you'll need three view controllers.


  1. BaseController (我称之为),由PKRevealController扩展,如何采取行动作为主内容控制器和导航控制器的基础。

  1. BaseController (i called it that), which get extended by the PKRevealController how's going to act as the base for the Main content controller and Navigation controller.

MainController ,设置为fronViewController。

MainController, which get set as the fronViewController.

NaviController ,我们基本上用作leftViewController,又名导航菜单。

NaviController, which we basically use as the leftViewController, aka navigation menu.

FYI:你可以从stroyboard设计和编码MainController和NaviController。

FYI: You can design and code the MainController and NaviController from the stroyboard.

所以这就是这个我们这样做;
首先我们需要像这样扩展我的BaseController和PKRevealController;

So this is how we do it; First we need to extend our BaseController with PKRevealController like this;

@interface MainController : PKRevealController

其次,仍然在BaseController中,将这些行添加到viewDidLoad方法;

Second, still in BaseController, add these line to the viewDidLoad method;

//init the fonrViewController
UIViewController *homeController = [self.storyboard instantiateViewControllerWithIdentifier:@"homeScreen"];
//init the leftViewController
UIViewController *naviContrlller = [self.storyboard instantiateViewControllerWithIdentifier:@"quickNaviScreen"];

[self setFrontViewController:homeController];
[self setLeftViewController:naviContrlller];

然后将PKRevealController委托设置为;

Then set the PKRevealController delegate as;

self.delegate = self;

就是这样。

这篇关于iOS将PKRevealController与Storyboard&自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆