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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM