-1
以下代碼將在commit
之後立即更新backgroundColor
。嵌套CATransaction的行爲?
[CATransaction begin];
self.view.backgroundColor = [UIColor redColor];
[CATransaction commit];
sleep(5);
,但只有在最外面的事務提交嵌套明確CATransactions
,屏幕更新。
[CATransaction begin];
[CATransaction begin];
self.view.backgroundColor = [UIColor redColor];
[CATransaction commit];
sleep(5);
[CATransaction commit];
所以這使得它很奇怪,因爲我們知道runloop會在每個循環中創建一個最外層的隱式事務。爲什麼implicit transaction
在explicit transaction
提交時不被視爲最外層交易?
所以,當需要大約嵌套事務,我們總是指向明確的交易? – Karl
是的,你的第二個例子是關於嵌套顯式事務,一個'begin ... commit'對彼此相對。顯式事務不是以任何有趣的方式嵌套在隱式事務中,因爲它是承諾的,因此與隱式事務稍後會做什麼無關。 – matt