سؤال

I have two UIViews, named A and B, and I add UIView B into A's subviews:

[A.view addSubview B]

I am wondering is there any delegation or hook that B can be informed "Oh, I was added into A!" when it was added to A? or any other way to let B know it was added to some other UIView container?

هل كانت مفيدة؟

المحلول

You can override the willMoveToSuperview: or didMoveToSuperview methods in a UIView subclass in order to be informed when the view is added to another view.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top