Вопрос

CustomView *customView = [...];
[self.view addSubview:customView];

I need to detect in my CustomView class when it is added in other views or when my superview changes.

Это было полезно?

Решение

You can use willMoveToSuperview: and didMoveToSuperview to detect when the view is moved around. layoutSubviews will be called when the superview changes frame.

Другие советы

  • For a UIView use - (void)didMoveToSuperview
  • For a UIViewController use -(void)viewWillAppear:(BOOL)animated

also assign THE TAG of Customview before addsubview and the detect by Particular TAG.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top