0
我想發佈通知沒有太多成功!我能做到這一點 確定爲鍵盤沒有問題,但現在我想一個自定義的 如下:通知未被識別
在我rootview我有這個
.H
-(void) allowEdits:(NSNotification *)notification;
.M
//this section is run in method to present the passcode entry form
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(allowEdits:) name: @"PasscodeOK" object:nil];
PasscodeEntryViewController *vc = [[PasscodeEntryViewController alloc]
init];
[self presentModalViewController: vc animated:YES];
[vc release];
// and this is the response to the notification
-(void) allowEdits:(NSNotification *)notification {
NSLog(@"notification fired");
}
// in the vc instance I have this to notify passcode was ok
[[NSNotificationCenter defaultCenter]
postNotificationName:@"PasscodeOK" object:nil];
[self dismissView];
但allowEdits永遠不會被調用?
嗨,是啊試過,但沒有喜悅!問題是要調用的方法在父級中,並且通知已發佈到子級中。從我可以看到的父母addObserver被忽略!這讓我瘋狂! 我只是不明白爲什麼它不會工作! – user7865437 2010-04-08 12:08:52
好歹徒!這一次我發現它!當我在幾周前實施通知時,我在viewDidDisappear方法中包含了一個調用來移除觀察者!所以我剛添加它......它被刪除了! DOH! – user7865437 2010-04-08 12:34:27