gpt4 book ai didi

iphone - 在现有的 Xcode Storyboard上使用 pkrevealcontroller

转载 作者:可可西里 更新时间:2023-11-01 06:22:11 25 4
gpt4 key购买 nike

我正在尝试将 pkrevealcontroller 滑动菜单集成到现有的 iOS 项目中,该项目具有带有 segues 等的现有 Storyboard。我扩展了 UINavigationViewController 并将我的新类链接到 Storyboard上的 Nav Controller。在我的应用委托(delegate)中,我执行以下操作:

MainNavViewController *frontViewController = [[MainNavViewController alloc] initWithRootViewController:[[myRootViewController alloc] init]];
UIViewController *rightViewController = [[menuViewController alloc] init];

self.revealController = [PKRevealController revealControllerWithFrontViewController:frontViewController
rightViewController:rightViewController
options:nil];

self.window.rootViewController = self.revealController;

当我运行应用程序时,它成功地将滑动菜单图标添加到导航栏,并且前 View 随我想要滑动。但它没有使用我在 Storyboard上添加的标题或 segues。我正在尝试的是什至可能的。

最佳答案

我认为问题在于您正在实例化一个新的 frontViewController —— 这不是您 Storyboard中的那个。我不确定该怎么做,但我会这样尝试。我会在 Storyboard 中添加一个 UIViewController——将其类更改为 PKRevealController,并使其成为 Storyboard 中的初始 Controller ,但不要将其连接到场景的其余部分。在 IB 中为您的 MainNavViewController 提供一个标识符,然后将您的应用委托(delegate)中的代码更改为:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.revealController = (PKRevealController *)self.window.rootViewController;
UIViewController *rightViewController = [[menuViewController alloc] init];
MainNavViewController *frontViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"frontViewController"];
[self.revealController setFrontViewController:frontViewController];
[self.revealController setRightViewController:rightViewController];
return YES;
}

关于iphone - 在现有的 Xcode Storyboard上使用 pkrevealcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14824959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com