首先上代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(0, 0, 400, 60)];
[button addTarget:self action:@selector(buttonDown) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Post Notification" forState:UIControlStateNormal];
[self.view addSubview:button];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionNotification:)
name:kNotificationName object:nil];
}
- (void) actionNotification: (NSNotification*)notification
{
NSString* message = notification.object;
NSLog(@"%@",message);
版权声明:本文为junjun150013652原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。