我正在尝试在收到通知后从超级视图中删除 UIViewController 但它不起作用。
在我的 appDelegate 我做这样的事情:
- (void)applicationDidFinishLaunching:(UIApplication *)application{
NSLog(@"applicationDidFinishLaunching");
[window addSubview:tabBar.view];
splash = [[SplashViewController alloc] init]; <-- this i want to remove
[window addSubview:splash.view];
[window makeKeyAndVisible]; }
在 SplashViewController 我注册视图以接收 NSNotifications,如下所示:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fadeScreen:) name:@"CloseSplashScreen" object:nil];
SplashViewController 出现在 Default.png 之后,并且在解析一些数据后应该平滑地消失......
在我的 TableViewControler 中,我想在 viewWillAppear 方法中发送通知,但它不起作用。
- (void)viewWillAppear:(BOOL)animated{
NSLog(@"viewWillAppear");
[[NSNotificationCenter defaultCenter] postNotificationName:@"CloseSplashScreen" object:self];}
该方法被调用,但视图没有从父视图中删除。我试图将 postNotification 放入 - (void)viewDidLoad 但该方法没有被调用...
任何想法为什么这不起作用?先感谢您