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

posted @ 2015-04-27 17:17  花园晓雨  阅读(4274)  评论(0编辑  收藏  举报