按下按钮会调用我的代码中的 View :
buttonlabel.text = @"Wait";
[self presentModalViewController:controller animated:YES];
buttonlabel.text = @"Done";
单击按钮后,我想立即将标签更改为“等待”。当前发生的情况是, View 的呈现需要 1-2 秒,并且标签仅在 1-2 秒过去后且 View 更改之前更改为“等待”。
将动画从 YES 更改为 NO 无济于事。
最佳答案
您需要将 View Controller 的呈现排队,以便系统有机会实际将按钮的文本更改为“等待”。如果您想了解更多信息,请谷歌 runloop iOS
.
buttonlabel.text = @"Wait";
dispatch_async(dispatch_get_main_queue(), ^{
[self presentModalViewController: controller animated: YES];
});
但是你真的应该调查一下为什么展示 VC 需要这么多时间,而是找到一种方法来优化你的代码。搜索合并并发性的方法,不要阻塞主线程。
关于iphone - 在presentmodalviewcontroller之前刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11833279/