zoukankan      html  css  js  c++  java
  • 05056简单kvo

        //kvo0506

    //    [_collectionView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];

     //kvo0506

    -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{

    //    //keypath 是观察的属性

    //    NSLog(@"---------keypath:%@",keyPath);

    //    //被观察的对象

    //    NSLog(@"---------object:%@",object);

    //    //新旧值

        NSLog(@"---------change:%@",change);//change是字典

    //

    //    NSLog(@"---------context:%@",context);

        

        if ([change[NSKeyValueChangeNotificationIsPriorKey]boolValue]) {

            NSLog(@"1");

            NSLog(@"值改变之前");

        } else{

    //        NSLog(@"2");

    //        NSLog(@"值改变之后");

        }

        

        

        

        //    self.view.backgroundColor = [UIColor greenColor];

        

        //context的作用就是传值/////////////////////////////

    //    ViewController *vc = (__bridge ViewController *)context;

    //    

    //    vc.view.backgroundColor = [UIColor greenColor];

     

     

     

    }

     

    -(void)dealloc{

        

        [_collectionView removeObserver:self forKeyPath:@"frame"];

    }

  • 相关阅读:
    hdu-4638
    一个简单的询问
    CoderForces-617B
    HYSBZ-2002弹飞绵羊
    邻接表
    CoderForces-913-C
    CoderForces-913D
    CoderFocers-620C
    CoderForces-375D
    HDU-6119
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5465745.html
Copyright © 2011-2022 走看看