使用 popViewController 在转换期间闪烁白色时出现问题

发布于 2024-11-13 21:21:19 字数 855 浏览 4 评论 0原文

我一直在努力使用 UINavigationalController 在视图之间切换。我已经多次使用这个系统,没有出现任何问题,但在我的新应用程序中它无法正常工作。

问题是这样的: 当我推送一个新的视图控制器时,我使用以下代码:

NewViewController *newVC = [[NewViewController alloc] initWithNib:@"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];

我用来返回到 newVC 内的上一个视图的代码是:

[self.navigationController popViewControllerAnimated:YES];

我读到这可能会释放 self.navigationController 本身,所以我实现了这段代码:

UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];

结果是平滑过渡到newVC,没有白色闪烁,但是当返回到原始页面时,屏幕闪烁白色,好像在过渡回原始页面之前释放了newVC。然而!调试时,我在原始页面的 viewWillAppear 和 newVC 的 dealloc 上以及带有白色闪存的 viewWillAppear + 转换上放置了断点,在调用 newVC 的 dealloc 之前全部完成。

如果有人可以帮助阐明这一点,我将不胜感激。

谢谢! 〜阿拉什

I have been struggling with switching between views using the UINavigationalController. I have used this system many times without issue but in my new app it isn't working properly.

Here is the issue:
When i am pushing a new view controller i use the following code:

NewViewController *newVC = [[NewViewController alloc] initWithNib:@"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];

The code I am using to return to the previous view inside of the newVC is:

[self.navigationController popViewControllerAnimated:YES];

I was reading that this could potentially be releasing the self.navigationController itself so I implemented this code:

UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];

What results is a smooth transition to the newVC with no white flash, but when returning to the original page the screen flashes white as if it is releasing the newVC before transitioning back to the original page. HOWEVER! When debugging I placed breakpoints on viewWillAppear of the original page and on the dealloc of the newVC and the viewWillAppear + transition with white flash all complete BEFORE the dealloc of the newVC is called.

If anyone could please help shine some light on this I would greatly appreciate it.

Thanks!
~Arash

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

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

发布评论

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

评论(3

伴梦长久 2024-11-20 21:21:19

这是一篇旧文章,但对于那些将来可能遇到这个问题的人,我已经通过将 ViewController 视图的 clipsToBounds 属性设置为“TRUE”来解决它

-(void)viewDidLoad {
    [super viewDidLoad];
    self.view.clipsToBounds = YES;
}

This is an old post, but for those who may run into this issue in the future, I have solved it by setting the clipsToBounds property of the view of the ViewController to "TRUE"

-(void)viewDidLoad {
    [super viewDidLoad];
    self.view.clipsToBounds = YES;
}
生活了然无味 2024-11-20 21:21:19

尝试将导航堆栈上各个视图的背景颜色更改为不同的可识别颜色(包括主窗口)。其中一个可能由于某种原因而显示,如果每一个都有不同的颜色,您可以很容易地确定哪一个是罪魁祸首。

Try changing the background colors of the various views on the navigation stack to different recognizable colors (including the main window). One of them might be showing for some reason, and if each one has a different color you can determine which one is the culprit pretty easily.

丢了幸福的猪 2024-11-20 21:21:19

FWIW,同样的问题也发生在我的 Swift 应用程序中。根本原因似乎是我这样做:

self.navigationItem.rightBarButtonItem = nil

...动态隐藏按钮,其中 UIBarButtonItem 在当前 UIViewController 中有一个出口。

我实际上并不需要该按钮的 IBOutlet,因此我删除了插座,并且它起作用了。

FWIW, this same issue happened for me in a Swift app. The root cause appeared to be that I was doing this:

self.navigationItem.rightBarButtonItem = nil

...to dynamically hide the button, where the UIBarButtonItem had an outlet in the current UIViewController.

I did not actually need an IBOutlet for that button, so I removed the outlet, and it worked.

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