gpt4 book ai didi

iOS:SWRevealViewController revealToggle 已被调用但什么都不做

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:54:33 24 4
gpt4 key购买 nike

我正在尝试在这种情况下实现 SWRevealViewController:

enter image description here从我的主视图 Controller :

-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SWRevealViewController *SWR = [storyboard instantiateViewControllerWithIdentifier:@"SWRevealViewController"];
[self presentViewController:SWR animated:YES completion:nil];
}

从我的绿色 View Controller :

-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
self.reveal = [[SWRevealViewController alloc] init];
self.reveal.delegate = self;
self.menu.target = self;
self.menu.action = @selector(revealToggleAction:);
[self.view addGestureRecognizer:self.reveal.panGestureRecognizer];
NSLog(@"viewDidLoad");
}

-(void)revealToggleAction:(id)sender
{
[self.reveal revealToggle:self];
}

已调用 revealToggle 操作,但未执行任何操作。它不会加载后视 Controller 。你们中有人知道发生这种情况或我做错了什么吗?

最佳答案

假设您从右侧显示侧边栏菜单。

首先将您的第一个 View Controller 嵌入到导航 Controller ,然后在您的第一个 View Controller viewdidload()viewDidAppear 方法中添加下面提到的代码即

//this is your side menu view controller.

UIViewController *sideMenuController =
[self.storyboard instantiateViewControllerWithIdentifier:@"YourSideMenuIdentifier"];

//this is the navigation controller embed to your green view controller.

UINavigationController *nc1 =
(UINavigationController *)[self.storyboard instantiateViewControllerWithIdentifier:@"YourNavigationControllerIdentifier"];

//This is your reveal view Controller.

SWRevealViewController *revealViewController =
[[SWRevealViewController alloc]initWithRightViewController:sideMenuController frontViewController:nc1];
[self.navigationController pushViewController:revealViewController animated:YES];
[self.navigationController setNavigationBarHidden:YES];

这将导航到 Controller ,即 Green View Controller。

然后在你的绿色 View Controller viewdidload()viewDidAppear 方法中添加下面提到的代码即

//GreenViewController.h file

@interface GreenViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIBarButtonItem *sideBarItem;
@end


//Your GreenViewController.m file

_sideBarItem.target = self.revealViewController;
_sideBarItem.action = @selector(rightRevealToggle:);
SWRevealViewController *revealController = [self revealViewController];
[self.view addGestureRecognizer:revealController.panGestureRecognizer];

注意:有关详细信息,请查看下面提到的链接

http://www.appcoda.com/ios-programming-sidebar-navigation-menu/

关于iOS:SWRevealViewController revealToggle 已被调用但什么都不做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43924741/

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