iOS中willMoveToSuperview:方法
直接看代码:
#import "CMoveView.h"
@interface CMoveView ()
//记录上一次父视图
@property (nonatomic, strong) UIView* oldSuperview;
@end
@implementation CMoveView
//当自己重写一个UIView的时候有可能用到这个方法,当本视图的父类视图改变的时候,系统会自动的执行这个方法.newSuperview是本视图的新父类视图.newSuperview有可能是nil.
- (void)willMoveToSuperview:(UIView *)newSuperview {
[super willMoveToSuperview:newSuperview];
NSLog(@"oldSuperview=%@,newSuperview=%@",self.oldSuperview,newSuperview);
self.oldSuperview = newSuperview;
NSLog(@"%s",__func__);
}
@end