gpt4 book ai didi

iphone - 翻转 View 时出现问题

转载 作者:行者123 更新时间:2023-12-03 21:14:08 28 4
gpt4 key购买 nike

我在翻转 View 时遇到了一些问题。我的 View Controller 中有以下代码:

- (void)loadFlipsideViewController {
ProblemViewFlipController *viewController = [[ProblemViewFlipController alloc] initWithNibName:@"ProblemViewFlip" bundle:nil];
self.problemViewFlipController = viewController;
[viewController release];
}


- (void) flipView {

if (problemViewFlipController == nil) {
[self loadFlipsideViewController];
}

UIView *mainView = self.view;
UIView *flipView = problemViewFlipController.view;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];

[UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.view cache:YES];

if ([flipView superview])
{
[flipView removeFromSuperview];
[self.view addSubview:mainView];
}
else
{
[mainView removeFromSuperview];
[self.view addSubview:flipView];
}

[UIView commitAnimations];
}

问题是,当我调用 FlipView 时, View 会被替换为空白 View (即我要翻转到的 View 中没有任何内容显示)。

我在这里遗漏了一些明显的东西吗? (我怀疑有!)

最佳答案

不是积极的,但我认为你需要使用“ Controller ”来翻转 View 。看起来您正在使用翻转 View 之一作为 Controller 。只需添加一个根 Controller 即可翻转您的 View 。

这样的代码应该在根 Controller 上工作:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; // self.view is the root controller's view
[mainViewController viewWillAppear:YES];
[flipViewController viewWillDisappear:YES];
[flipViewController.view removeFromSuperview];
[self.view addSubview:mainViewController.view];
[flipViewController viewDidDisappear:YES];
[mainViewController viewDidAppear:YES];
[UIView commitAnimations];

关于iphone - 翻转 View 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/682388/

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