ZUUIRevealController - 通过按后控制器中的表格视图单元格将视图推送到前视图上

发布于 2025-01-06 08:54:37 字数 907 浏览 1 评论 0原文

我正在使用很棒的库 ZUUIRevealController。但是,我无法对其进行编程,以便用户能够点击后控制器中的单元格。然后后控制器应该消失并在前视图中显示一个新的视图控制器。

我已经这样设置了我的项目:

    VGViewController *frontViewController;
RevealController *rearViewController;

frontViewController = [[VGViewController alloc] initWithNibName:@"VGViewController" bundle:nil];

self.navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

rearViewController = [[RevealController alloc] initWithNibName:@"RevealController" bundle:nil];

ZUUIRevealController *revealController = [[ZUUIRevealController alloc] initWithFrontViewController:self.navigationController rearViewController:rearViewController];

[frontViewController release];
[rearViewController release];

self.window.rootViewController = revealController;
[revealController release];
[self.window makeKeyAndVisible];
return YES;

我希望有人可以帮助我! :D

i'm playing around with the great library ZUUIRevealController. However, I can't program it so the user are able to tap a cell in the rearcontroller. The rearcontroller should then go away and display a new viewcontroller in the front view.

I've setup my project like this:

    VGViewController *frontViewController;
RevealController *rearViewController;

frontViewController = [[VGViewController alloc] initWithNibName:@"VGViewController" bundle:nil];

self.navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

rearViewController = [[RevealController alloc] initWithNibName:@"RevealController" bundle:nil];

ZUUIRevealController *revealController = [[ZUUIRevealController alloc] initWithFrontViewController:self.navigationController rearViewController:rearViewController];

[frontViewController release];
[rearViewController release];

self.window.rootViewController = revealController;
[revealController release];
[self.window makeKeyAndVisible];
return YES;

I hope someone can help me! :D

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2025-01-13 08:54:37

很高兴您在图书馆找到了自己喜欢的东西。

如果我没有遗漏任何东西,你的项目似乎设置正确,尽管从逻辑上讲我无法遵循后视图控制器<=>的方式。 RevealController 但我想没关系。

回答你的问题:
为了通过点击rearViewController中的单元格来显示不同的frontViewController,您需要在适当的方法中触发这段代码(例如:tableView:didSelelctRowAtIndexPath:)

// RearViewController.m file in some method:
// - Let's grab a reference to the revealController first:
ZUUIRevealController *revealController = [self.parentViewController isKindOfClass:[ZUUIRevealController class]] ? (ZUUIRevealController *)self.parentViewController : nil;

// Check if we're not attempting to swap the current FrontViewController for exactly the same controller over again...
if (![revealController.frontViewController isKindOfClass:[NewFrontViewController class]])
{
        NewFrontViewController *newFrontViewController;

        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        {
            newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPhone" bundle:nil];
        }
        else
        {
            newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPad" bundle:nil];
        }

        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:newFrontViewController];
        [newFrontViewController release];
        [revealController setFrontViewController:navigationController animated:NO];
        [navigationController release];
}

这段代码的作用是,它获取对afterViewControllers 父级(应该是 RevealController),并通过调用 [revealController setFrontViewController:navigationController 为其分配一个新的 frontViewController 实例动画:NO];

希望这能解决您的问题:-)

glad you found a liking in the library.

Your project seems to be setup correctly if I'm not missing anything, although logically I'm not able to follow how the rearViewController <=> RevealController but that's okay I guess.

To answer your question:
In order to display a different frontViewController by, say tapping on a cell in the rearViewController you need to trigger this piece of code in the appropriate method (say: tableView:didSelelctRowAtIndexPath:)

// RearViewController.m file in some method:
// - Let's grab a reference to the revealController first:
ZUUIRevealController *revealController = [self.parentViewController isKindOfClass:[ZUUIRevealController class]] ? (ZUUIRevealController *)self.parentViewController : nil;

// Check if we're not attempting to swap the current FrontViewController for exactly the same controller over again...
if (![revealController.frontViewController isKindOfClass:[NewFrontViewController class]])
{
        NewFrontViewController *newFrontViewController;

        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        {
            newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPhone" bundle:nil];
        }
        else
        {
            newFrontViewController = [[NewFrontViewController alloc] initWithNibName:@"NewFrontViewController_iPad" bundle:nil];
        }

        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:newFrontViewController];
        [newFrontViewController release];
        [revealController setFrontViewController:navigationController animated:NO];
        [navigationController release];
}

What this piece of code does is, it grabs a reference to the rearViewControllers parent (which should be the revealController), and assigns a new frontViewController instance to it by calling [revealController setFrontViewController:navigationController animated:NO];

Hope this solves your problem :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文