dat*_*inc 5 objective-c ios ios8
在iOS 7中,我的应用程序在应用程序进入后台(通过订阅UIApplicationDidEnterBackgroundNotification)时显示了身份验证屏幕.身份验证控制器删除了敏感信息,因此后台屏幕截图未显示任何用户信息.在iOS 8中,这不再起作用.后台截图现在显示用户上次工作的视图而不是身份验证控制器...即使应用程序返回到前台,身份验证控制器也处于活动状态.
我现在找到了一个工作.而不是使用UIApplicationDidEnterBackgroundNotification我可以使用,name:UIApplicationWillResignActiveNotification但这会导致用户离开应用程序时闪光.
这是一个错误还是苹果提供了一种从移动到后台之前从视图中删除敏感信息的新方法.
注意:将ignoreSnapshotOnNextApplicationLaunch在applicationWillResignActive:
和applicationDidEnterBackground:没有帮助.
更新:创建了错误报告
与@ Gurudev0777相似的方法,但是使用UIBlurEffect来遮盖内容,并且没有担心不同设备屏幕指标的缺点。应用程序委托:
#define MY_BACKGROUND_SCREEN_TAG 1001//or any random but UNIQUE number.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Visual effect view for blur
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[blurView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[blurView setFrame:self.window.frame];
blurView.tag = MY_BACKGROUND_SCREEN_TAG;
[self.window addSubview:blurView];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// remove blur view if present
UIView *view = [self.window viewWithTag:MY_BACKGROUND_SCREEN_TAG];
if (view != nil)
{
[UIView animateWithDuration:0.2f animations:^{
[view setAlpha:0];
} completion:^(BOOL finished) {
[view removeFromSuperview];
}];
}
}
Run Code Online (Sandbox Code Playgroud)
奇迹般有效...
2015年5月18日编辑:感谢@Simeon Rice对模态对话框的观察,修订后将模糊视图添加到self.window而不是rootViewController.view
编辑于8/23/2016:感谢@tpankake的观察re:自动调整大小的蒙版。
小智 -1
here we are putting an imageview while the app animate to background -
-(void)applicationWillResignActive:(UIApplication *)application
{
imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];
[imageView setImage:[UIImage imageNamed:@"Default@2x.png"]];
[self.window addSubview:imageView];
}
Here is the code to remove the imageview:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if(imageView != nil) {
[imageView removeFromSuperview];
imageView = nil;
}
}
It is working and tested many times.
*** Please test this scenario into the device not in simulator.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1451 次 |
| 最近记录: |