你好我在appdelegate.m的方法中分配nsnotifiaction,这个方法每30秒调用一次eprox,我希望它在viewcontroller和execute方法中的通知,这是我的appdelegate.m代码
- (void)layoutAnimated:(BOOL)animated{
BOOL yy= self.bannerView.bannerLoaded;
if (yy==1){
self.iAdString=[NSMutableString stringWithString:@"1"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"BannerViewActionWillBegin" object:self];
}
else{
self.iAdString=[NSMutableString stringWithString:@"0"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"BannerViewActionDidFinish" object:self];
}
}
在 viewcontroller.m
//我在viewdidload方法中定义
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willBeginBannerViewActionNotification:) name:@"BannerViewActionWillBegin "object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishBannerViewActionNotification:) name:@"BannerViewActionDidFinish" object:nil];
}
它的方法是..
- (void)willBeginBannerViewActionNotification:(NSNotification *)notification{
[self.view addSubview:self.app.bannerView];
NSLog(@"come");
}
- (void)didFinishBannerViewActionNotification:(NSNotification *)notification {
NSLog(@"come");
[self.app.bannerView removeFromSuperview];
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
在 appdelegate 文件中读取方法时,我没有得到过多方法的响应。
请帮我。