我不明白爲什麼UIView的removeFromSuperview
正在調用didMoveToSuperview
。UIView removeFromSuperview is calling didMoveToSuperview
我認爲didMoveToSuperview
僅在視圖添加到視圖時纔會調用。任何人都可以解釋爲什麼removeFromSuperview
調用didMoveToSuperview
?
下面是我在做什麼在removeFromSuperview
:
public override func removeFromSuperview() {
clearDelegates()
chaosPad?.removeFromSuperview()
brushSliders?.removeFromSuperview()
moodSlider?.removeFromSuperview()
brushShapeMenu?.removeFromSuperview()
moodMenu?.removeFromSuperview()
gravityMenu?.removeFromSuperview()
rotationMenu?.removeFromSuperview()
menuGroups = []
centerButtons = []
scrollMenuItems = []
menu?.removeFromSuperview()
menu = nil
super.removeFromSuperview()
}
func clearDelegates() {
chaosPad?.delegate = nil
viewController = nil
}
這裏是在didMoveToSuperview
怎麼叫調用堆棧:
#0 0x0000000110f39708 in specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt) ->()()
#1 0x000000010b9cb960 in TDTOilistMenuPainting.configureFrames() ->() at /FastDev/TDTPhotoLib/Oilist/Classes/TDTOilistMenuPainting.swift:161
#2 0x000000010b9cb83e in TDTOilistMenuPainting.didMoveToSuperview() ->() at /FastDev/TDTPhotoLib/Oilist/Classes/TDTOilistMenuPainting.swift:146
#3 0x000000010b9cb872 in @objc TDTOilistMenuPainting.didMoveToSuperview() ->()()
#4 0x000000010f5d1db5 in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke()
#5 0x000000010dc87c60 in -[NSISEngine withBehaviors:performModifications:]()
#6 0x000000010f5d19b1 in -[UIView(Hierarchy) _postMovedFromSuperview:]()
#7 0x000000010f5cf610 in __UIViewWasRemovedFromSuperview()
#8 0x000000010f5cf107 in -[UIView(Hierarchy) removeFromSuperview]()
#9 0x000000010b9c9aba in TDTOilistMenuPainting.removeFromSuperview() ->() at /FastDev/TDTPhotoLib/Oilist/Classes/TDTOilistMenuPainting.swift:73
#10 0x000000010ba6d269 in TDTPaintingViewController.(navigationController(UINavigationController, animationControllerForOperation : UINavigationControllerOperation, fromViewController : UIViewController, toViewController : UIViewController) -> UIViewControllerAnimatedTransitioning?).(closure #2) at /FastDev/TDTPhotoLib/Oilist/Classes/TDTPaintingViewController.swift:2706
你的意思是說:「我倒覺得'didMoveToSuperview'是隻有在視圖添加到視圖時才調用「? – TylerTheCompiler
是的,謝謝,我編輯了這篇文章。 –