Я пытался скрыть данные, когда приложение переходит в фоновое состояние, скрывая их в переключателе задач.
вот мой AppDelegate.h файл
@interface AppDelegate : UIResponder
<
UIApplicationDelegate,
MemberServicesManagerDelegate
>
{
UIWindow* window;
Reachability* reachbility;
}
@property(nonatomic, strong) UIViewController *mainViewController;
@end
Это мой AppDelegate.m файл
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{ window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
window.rootViewController = StartupController.instance.startingViewController;
if(DEVICE == IPAD){
self.mainViewController = window.rootViewController.childViewControllers[0];
}
[window makeKeyAndVisible];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
//1
//self.window.hidden = YES;
//2
//UIViewController *image = [UIViewController new];
//image.view.backgroundColor = [UIColor blackColor];
//[window makeKeyAndVisible];
//[window.rootViewController presentViewController:image animated:NO completion:NULL];
//3
UIView *colourView = [[UIView alloc]initWithFrame:window.frame];
colourView.backgroundColor = [UIColor blackColor];
colourView.tag = 1234;
colourView.alpha = 0;
[window addSubview:colourView];
[window bringSubviewToFront:colourView];
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 1;
}];
NSLog(@"BACK");
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
//1
//self.window.hidden = NO;
//2
//[window.rootViewController dismissViewControllerAnimated:NO completion:NO];
//3
UIView *colourView = [window viewWithTag:1234];
[UIView animateWithDuration:0.5 animations:^{
colourView.alpha = 0;
} completion:^(BOOL finished) {
[colourView removeFromSuperview];
}];
NSLog(@"ForeGround");
}
Я попробовал эти 3 реализации, но при входе в многозадачный коммутатор он не будет скрывать вид.
Я пробовал это как на симуляторе, так и на реальном устройстве, но он все равно не будет работать. Можете ли вы помочь мне с этим?