Ios 当应用程序转到后台时,如何获得通知?

Ios 当应用程序转到后台时,如何获得通知?,ios,Ios,在进入后台之前,我需要保护我的应用程序不被截图。我在ApplicationIdentinterBackground:中添加了一个黑色视图。但当我在iOS7模拟器中检查后台应用程序时,它并没有显示黑色图像,而是显示应用程序本身,如图所示。我怎样才能解决这个问题?如果我在应用程序启动前得到通知,这个问题可能会得到解决。任何帮助都将不胜感激 您将在AppDelegate的ApplicationIdentinterBackground中得到一个回调。要在整个应用程序中实现您想要的功能,最好的方法是让您的

在进入后台之前,我需要保护我的应用程序不被截图。我在
ApplicationIdentinterBackground:
中添加了一个黑色视图。但当我在iOS7模拟器中检查后台应用程序时,它并没有显示黑色图像,而是显示应用程序本身,如图所示。我怎样才能解决这个问题?如果我在应用程序启动前得到通知,这个问题可能会得到解决。任何帮助都将不胜感激

您将在AppDelegate的
ApplicationIdentinterBackground

中得到一个回调。要在整个应用程序中实现您想要的功能,最好的方法是让您的应用程序导航到一个全黑的UIViewController。这样,当您长按Home按钮并查看后台应用程序时,将看不到任何内容

这两个函数将实现以下功能:

- (void) applicationDidEnterBackground:(UIApplication *)application
{
    //navigate to the black view controller
    BlackViewController *controller = [[BlackViewController alloc] init];

    [yourNavigationController pushViewController:viewController animated:yourAnimationSettings];

    [controller release];   
}

- (void) applicationWillEnterForeground:(UIApplication *)application
{
    //pop the black view controller so the user won't be bothered with it
    if(/*Check if your BlackViewController is the top of your navigationController stack*/)
    {
         [yourNavigationController popViewControllerAnimated:yourAnimationSettings];
    }
} 

在de ApplicationIdentinterBackground中:已在UIViewController上调用ViewWillEnglish。这可能是您无法更改当前UIViewController外观的原因。我建议导航到一个完全黑色的UIViewController,而不是更改当前的UIViewController。因为这仍然在您的可能范围内(因为您可能从appDelegate中启动了navigationController?),您的意思是说,应用程序屏幕截图逻辑将出现在视图中,并且视图控制器将消失?是的,那可能也行。那可能行,但我在一个大项目中工作。我不会在1/2文件中添加屏幕截图逻辑。我需要在appdelegate本身中编写它。然后将它导航到黑色UIViewController可能是使其工作的最佳解决方案。我完全理解您的概念。将在调用ApplicationIdentinterBackground:方法之前拍摄屏幕截图。这就是为什么会出现上述问题。您如何防止用户使用第二部手机复制您的屏幕?你可以而且永远也不会完全阻止每一种滥用应用程序的方式。如果应用程序将进入前台:对您不起作用。也许其他协议方法之一会?