我有一个应用程序,有一个登录视图,然后登录成功后,我想有一个边菜单视图。我正在使用SWRevealViewController制作幻灯片菜单。但问题是,正如我所说的,登录视图将是第一个视图,而不是SWRevealViewController。我尝试在prepareForSegue方法中执行以下操作。
SWRevealViewController *revealViewController;
[revealViewController initWithRearViewController: [self.storyboard instantiateViewControllerWithIdentifier:@"MenuTableViewCell"]frontViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"]];这不管用。这是我在prepareForSegue方法中唯一的代码,我删除了IF语句,因为我在loginview中只有一个segue,所以我想我不需要if。我应该从故事板中删除SWRevealViewController吗?或者从登录视图到SWRevealViewController,我不知道该做什么。对于视图中使用SWRevealViewController的情况没有任何解释,而不是第一个视图。我正在为iOS为iPhone的目标c构建这个应用程序。请帮帮忙。谢谢。
发布于 2016-02-13 07:17:45
你应该像这样做你的故事板层次结构。
这应该是你的故事板的设置。

下面是编码部分:
In SWRevealViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userSignedInSuccessfully) name:kUserSignedInNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userSignOutSuccessfully) name:kUserSignedOutNotification object:nil];
// this flag should be maintained in user defaults
if(iSUserSignedIn){
//Show Home page if user is already signed in
[self showHomeScreen];
}
}
#pragma mark - Show Home screen
-(void)showHomeScreen
{
UINavigationController *navigation = [[UIStoryboard storyboardWithName:kStoryboardName bundle:nil] instantiateViewControllerWithIdentifier:@"HomeNavigationController"];
[self setFrontViewController:navigation];
[self setFrontViewPosition:FrontViewPositionLeft];
}
-(void)showLoginScreen{
UINavigationController *navigation = (UINavigationController *)[[UIStoryboard storyboardWithName:kStoryboardName bundle:nil] instantiateViewControllerWithIdentifier:@"LoginNavigationController"];
[self setFrontViewController:navigation];
[self setFrontViewPosition:FrontViewPositionLeft];
}现在,当用户第一次签名时,在默认情况下保存标志iSUserSignedIn并发布此通知。
//Post notification for successful sign in
[[NSNotificationCenter defaultCenter] postNotificationName:kUserSignedInNotification object:nil];当用户签出set标志iSUserSignedIn为零并发布此通知时。
//Post notification for successful sign out
[[NSNotificationCenter defaultCenter] postNotificationName:kUserSignedOutNotification object:nil];https://stackoverflow.com/questions/35375998
复制相似问题