您的位置:首页 > 移动开发 > IOS开发

iOS 通知的使用,以及场景(未确定版本)

2015-10-21 13:59 691 查看
 

首先我们要再处理事件的视图里面创建通知(比如。视图里面的按钮被点击了,但是这个事件不能在视图里面解决,就需要用通知)

一、首先

//创建通知

    NSNotification *notification =[NSNotification
notificationWithName:@"tongzhi"
object:nil];

   
//通过通知中心发送通知

    [[NSNotificationCenter
defaultCenter] postNotification:notification];

(创建场景。 一般在按钮点击事件里面写)

一、其次 

以下的步骤一般都要写在控制器里面

在ViewDidLoad 中 注册通知在selector方法里面写一个想要调用的方法, 一般可随机定义

- (void)viewDidLoad {

    [super
viewDidLoad];

    //注册通知

    [[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(shouldBtnOnClick)
name:@"tongzhi"
object:nil];
}

#pragma mark - 通知的实现方法

- (void)shouldBtnOnClick

{

    [MessageView
showAlertMoney:@"200"
SureTitle:@"确定"
sureOption:^{

        NSLog(@"111111");

    } cancelTitle:@"取消"
cancelOption:^{

        NSLog(@"2222222");

    } inView:self.view];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: