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.
- (void)didMoveToSuperview
-(void)viewWillAppear:(BOOL)animated
还要在 addsubview 之前分配 Customview 的标签,并通过特定标签进行检测。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.