gpt4 book ai didi

ios - Container V 中的父 subview

转载 作者:行者123 更新时间:2023-11-28 22:32:12 25 4
gpt4 key购买 nike

我在 iOS 中有一个项目,我正在尝试修改它以在另一个项目中使用。该项目运行良好,但当我尝试将侧 View Controller 嵌入选项卡栏 Controller 时出现错误

**MFSideMenuDemoStoryboard[23760:c07] -[UITabBarController setLeftMenuViewController:]: unrecognized selector sent to instance 0x757a590
2013-06-13 10:08:51.062 MFSideMenuDemoStoryboard[23760:c07] **** * * **Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController setLeftMenuViewController:]: unrecognized selector sent to instance 0x757a590'**

我知道 appDelegate .m 中的代码有问题,但无法弄清楚

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;

UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];


UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
UIViewController *rightSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"rightSideMenuViewController"];


[container setLeftMenuViewController:leftSideMenuViewController];
[container setRightMenuViewController:rightSideMenuViewController];
[container setCenterViewController:navigationController];

return YES;
}

这是我的 Storyboard

enter image description here

最佳答案

您的 Root View Controller 不是 MFSideMenuContainerViewController。它是一个 UITabBarController。如果您想使用 MFSideMenuContainerViewController,您需要查看文档:https://github.com/mikefrederick/MFSideMenu/

这是一个基本的例子:

UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
UIViewController *rightSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"rightSideMenuViewController"];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController: self.window.rootViewController
leftMenuViewController: leftSideMenuViewController
rightMenuViewController: rightSideMenuViewController];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];

这将用 MFSideMenuContainerViewController 替换现有的 Root View Controller ,并将旧的 Root View Controller 作为中心 View Controller 。

关于ios - Container V 中的父 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17079006/

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