zoukankan      html  css  js  c++  java
  • 页面跳转和类间通讯

    和ios开发中的"观察者"模式很相似----那就是NSNotificationCenter

    在说这个之前,得提前说明一下"观察者"是什么来,在ios里,道先是观察者想要观察消息中心里的消息,那么就必须在消息中心里加入注册,可以用以下语句进行注册

        // 第一个参数为self,表示将self设为观察者来观察通知,

        // 第二个参数@selector(setData:)表示收到符合条件的通知后要执行方法setData:

        // 第三个参数kNotificationMessage为指定的要观察的通知的名称,一般可为NotificationMessage;

        // 第四个参数为nil,表示任何对象发过来的通知都可以被观察到

        [[NSNotificationCenter defaultCenteraddObserver:self selector:@selector(setData:)name:kNotificationMessage object:nil];

    注册完成后,当消息中心有数据响应时,会响应setData方法.可以看参数说明.

    至于发送信息的话,如下:

    // 第一个参数表示发出的通知的名称

            // 第二个参数表示谁发出的通知

            // 第三个参数表示通知所带的信息

            [[NSNotificationCenter defaultCenterpostNotificationName:kNotificationMessage object:self userInfo:infoDict];

    还有一点要先说明的,使用者要先注册,信息响应再响应,然后观察者才会接收,顺序如下:

    注册---->发送信息----->接收

     

     

    除了UINaviigation和addSubView之外的页面跳转:presentModalViewController:  dismissModalViewController:

    ValueInputView *valueView = [[ValueInputView allocinitWithNibName:@"ValueInputView"bundle:[NSBundle mainBundle]];

        valueView.delegate = self;

        [self setModalTransitionStyle:UIModalTransitionStyleCoverVertical];

        [self presentModalViewController:valueView animated:YES];

     

  • 相关阅读:
    OpenCV中threshold函数的使用
    opencv中namedWindow( )函数
    Open CV leaning
    RGB颜色表
    visual studio 2015 Opencv4.0.1配置
    uint16_t
    Arduino重置-复位问题
    bzoj1823 [JSOI2010]满汉全席(2-SAT)
    bzoj2208 [Jsoi2010]连通数(scc+bitset)
    UVAlive3713 Astronauts(2-SAT)
  • 原文地址:https://www.cnblogs.com/hellocby/p/2640317.html
Copyright © 2011-2022 走看看