gpt4 book ai didi

iphone - ZUUIRevealController - 通过按后 Controller 中的表格 View 单元格将 View 推送到前 View 上

转载 作者:行者123 更新时间:2023-12-03 19:41:39 24 4
gpt4 key购买 nike

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

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

    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

最佳答案

很高兴您喜欢图书馆。

如果我没有遗漏任何东西,你的项目似乎设置正确,尽管从逻辑上讲我无法遵循rearViewController <=> 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];
}

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

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

关于iphone - ZUUIRevealController - 通过按后 Controller 中的表格 View 单元格将 View 推送到前 View 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9328129/

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