- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试在这种情况下实现 SWRevealViewController:
-(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/
我正在尝试在这种情况下实现 SWRevealViewController: 从我的主视图 Controller : -(void)viewDidAppear:(BOOL)animated {
我在我的应用程序中使用 SWRevealController 并遵循此处描述的说明:http://www.appcoda.com/ios-programming-sidebar-navigation-
我正在尝试实现 SWRevealViewController但是在尝试将切换绑定(bind)到我的选项卡栏(而不是像他们在示例中建议的那样的导航栏或按钮)时遇到一些问题。 在他们的文档教程中,他们这样
我是一名优秀的程序员,十分优秀!