我在@interface和@end之间声明了一个UIWindow,如下所示:
@interface
@property (strong,nonatomic) UIWindow *aWindow;
@end
然后我在viewDidLoad
中初始化它- (void)viewDidLoad {
_aWindow = [UIWindow alloc] initWithFrame:aFrame;
_aWindow.backgroundColor = [UIColor redColor];
_aWindow.windowLevel = UIWindowLevelNormal;
}
现在我想通过在NotificationCenter块中调用removeFromSuperview来删除此窗口:
[[NSNotificationCenter defaultCenter] addObserverForName:CloseWindowNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[self.aWindow removeFromSuperview];
self.aWindow = nil;
}
它无法正常工作。在调用它之后,这个窗口仍然存在。
我尝试将self.aWindow = nil
放在此块之外,它可以正常工作。我也尝试使用UIWindowLevelNormal
,并成功将其删除。
任何人都可以告诉我为什么我无法删除阻止内部的这个窗口? 谢谢!