- (void)viewWillAppear:(BOOL)animated{{ [super viewWillAppear:animated]; [self.navigationController popViewControllerAnimated:YES];}代码可以很好地编译,但是当您导航到 View #2 时,您将获得以下日志:The code will compile just fine, but when you navigate to View #2 you will get the following log:嵌套的流行动画会导致导航栏损坏"基本上这就是我在流行后色调颜色变化时遇到的问题.popViewControllerAnimated 方法在代码中足够深,它没有被 Xcode 捕获,但到目前为止还没有造成一系列问题.And essentially that is the problem that I was experiencing with the tint colors changing after the pop. The method popViewControllerAnimated was deep enough in the code that it was not caught by Xcode, but not so far that it didn't create a bunch of problems.我采取的解决方法如下:The workaround that I did was the following:创建一个 BOOL 变量 @property (nonatomic) BOOL didFail;首先在 willViewAppear 中将 BOOL 变量设置为 FALSE调用测试条件的方法(在willViewAppear内)如果条件失败,将 BOOL 变量设置为 TRUE在 viewDidAppear 内检查 BOOL 变量是否为真或不是.如果条件是您要查找的内容,则弹出一个视图.Create a BOOL variable @property (nonatomic) BOOL didFail;Set the BOOL variable to FALSE first thing in willViewAppearCall the method (within willViewAppear) that tests the conditionIf condition fails, set BOOL variable to TRUEWithin viewDidAppear check to see if the BOOL variable is true ornot. Pop up one view if condition is what you are looking for.代码:.h 文件@property (nonatomic) BOOL didFail;.m 文件- (void)viewWillAppear:(BOOL)animated{{ [super viewWillAppear:animated]; self.didFail = FALSE; [self methodCall];}- (void) methodCall{ if(condition is met){ self.didFail = TRUE; }}- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; if(self.didFail == TRUE){ //alert message [self.navigationController popViewControllerAnimated:YES]; }}然后就可以了.在警报出现之前有一个轻微的停顿,但可以忽略不计.现在,在流行音乐之后,一切都完全正常!And that'll about do it. There is a slight pause before the alert shows up, but it is negligible. And now after the pop everything is exactly as it should be! 这篇关于使用 popViewControllerAnimated 时按钮色调会改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 15:40