0

我正在使用 SWRevealViewController 库。使用 AppCoda 教程(也非常好),我设法让它运作良好。但是,我现在已经配置了一个“设置”屏幕,我想在其中将内容保存到 Core Data 中,然后将屏幕弹出回主屏幕。

因为设置屏幕有一个嵌入式导航栏,而 iOS 7 不允许导航栏中的导航栏,所以我使用了一种变通方法来调用它。

// Get the view controller
UIViewController *vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:vcName];


// Swap out the Front view controller and display
[self.revealViewController setFrontViewController:vcNew];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

我现在不知道该怎么做,是如何弹出这个。

标准:[self.navigationController popViewControllerAnimated:YES]; 和 [self dismissViewControllerAnimated:YES 完成:nil];

似乎根本不起作用。

我从 John Lluch 的文档中注意到,现在有必要使用“pushFrontViewController”。但是,我不清楚如何做到这一点。

我假设我使用这样的东西:

[self.revealViewController pushFrontViewController:<(UIViewController *)> animated:<(BOOL)>]

但是 UIViewController 的身份是什么?

4

3 回答 3

4

线索当然在我问的问题中:

我只是使用了 sw_rear viewcontroller 的标识符并执行了以下操作。

// Get the view controller
UIViewController *vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"SW_FRONT_ID_GOES_HERE!!!"];

// Swap out the Front view controller and display
[self.revealViewController setFrontViewController:vcNew];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

简单的...

于 2014-08-15T21:59:06.253 回答
1

我不知道 SWRevealController 库,但在顶部放置新视图控制器的通用方法就是展示它......

*vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:vcName];
// btw, if you're inside another view controller from the same storyboard, you can
// use self.storyboard instead of the longer 'storyboardWithName'
[self presentViewController:vcNew animated:YES completion:^{
    // this block runs when the present animation completes
    // you can usually do nothing in here
}];

如果由于某种原因这不起作用,请尝试在您的 SWReveal 库容器上显示它,就像这样(我怀疑您是否需要这样做)...

[self.revealViewController presentViewController:vcNew // ... and so on

如果您保留指向它的指针,则可以从呈现它的同一视图控制器中将其关闭,否则,通常更容易不保留指针并在完成后设置 vc 自行关闭...

// in SettingsViewController.m
// when it's time to dismiss
[self dismissViewControllerAnimated:YES completion:^{}];

另外,只是重读您的帖子,我猜测应该在文档 pushFrontViewController 中使用哪个视图控制器将是您想要的前面,即vcNew

于 2014-08-15T21:52:14.893 回答
0

Popview 是您要导航的视图。根据您在 (UIViewController *) 位置的问题,viewcontroller 的对象将放置。

像这样:

MainVC *mv = [[MainVC alloc]init];
    UINavigationController *mnav = [[UINavigationController alloc]initWithRootViewController:mv];
    [reveaself.revealViewController pushFrontViewController:mnav animated:YES];

这样,您可以像流行音乐一样导航。

于 2014-09-01T12:18:31.427 回答