2017-11-19 4 views
0

(11)가 나는 blur effect를 만들려면 다음 코드를 사용하는 아이폰 OS에서 작동이 중지 그것은 iOS 10에 잘 작동하지만, .I는 blur 응용 프로그램으로 이동 background에 .When 응용 프로그램을 볼 수 아니다 iOS 11에 작동이 중지 foreground, 어떤 때는 blur stays always에오고 더 이상 작동하지 않는 응용 프로그램은 relaunching에 의해 작동합니다.흐림 효과는

iOS 11에 대한 해결 방법이 있습니까?

-(void)addBlurEffect{ 
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 
    UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 
    UIWindow * window = [[UIApplication sharedApplication] keyWindow]; 
    blurEffectView.frame = window.frame; 
    blurEffectView.tag = 4444; 
    [window addSubview:blurEffectView]; 

} 

-(void)removeBlurEffect{ 
    NSArray *allWindows = [[UIApplication sharedApplication] windows]; 
    for (UIWindow * aWindow in allWindows) { 
     UIView *blurEffectView = [aWindow viewWithTag:4444]; 
     if (blurEffectView){ 
      [blurEffectView removeFromSuperview]; 
     } 
    } 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application { 
    [self addBlurEffect]; 
} 


- (void)applicationWillEnterForeground:(UIApplication *)application { 
    [self removeBlurEffect]; 
} 
+0

이 앱이 배경에있을 때 흐림 효과를 추가 할 어떤 의미가 않습니다 .. 추측? 앱이 백그라운드에서 실행되고 있지 않습니다. 볼 것이 없다. 이 코드는 무엇을하려고합니까? – matt

+0

앱에 안전상의 이유로 백그라운드에서 아무것도 표시하지 않으려면 앱 화면을 숨기고 상단에보기를 추가 할 수 있습니다. – Ellen

답변

0

전체 참석자가 위젯을 잘못 쓰고 있기 때문에 이러한 현상이 발생합니다. 게임이에 갈 때 당신은 ..

- (void)applicationWillResignActive:(UIApplication *)application { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 

    [self addBlurEffect]; 
} 

- (void)applicationDidBecomeActive:(UIApplication *)application { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 

    [self removeBlurEffect]; 
} 

그래서 "일시 중지"또는 게임을 "일시 중지 상태를 해제"로 위의 두 가지 방법을 생각 .. 문서 또는 각각의 방법이 무엇에 AppDelegate의 주석을 읽을 필요 백그라운드 또는 인터럽트가 발생하면 일반적으로 사용자를 위해 일시 ​​중지하므로 백그라운드 상태 또는 전환 상태 (IE : 작업 관리자 상태)에있는 동안 진행률이 떨어지거나 죽지 않습니다.

그런 다음 앱이 다시 시작되고 앱이 화면에 표시되면 일시 중지됩니다. 이 방법은 상태를 저장하고 청소입니다

- (void)applicationDidEnterBackground:(UIApplication *)application { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

.. 수정하지 :이 상쾌하고 핸들 위의 두 가지 방법 .. 그러나

는, 당신이 그 일을했다 .. 어떤 그래픽의 무효화를 요구한다 UI .. IE : 데이터를 데이터베이스에 저장하거나 사용자 설정을 디스크 또는 다른 것으로 동기화하거나 메모리를 해제하는 중 ... 사용자가이 상태에서 앱을 죽일 수 있거나 시스템에서이를 종료 할 수도 있습니다.

이것은 애플리케이션이 실제로 최소화되었을 때만 호출됩니다 (최소화/배경 상태는 작업 전환기 상태/비활성 상태와 다릅니다!). iOS 11은 다른 전환점을 갖기 때문에 실제로 차이점을 확인합니다 나는

당신이 활성 상태 핸들러가 100 % 잘 작동에 코드를 이동하면 ..

+0

iOS 11에서 다른 전환 스타일이 있다고 말했듯이 흐림 효과가 추가되지 않는 경우가 있습니다. 장치 홈 버튼을 두 번 누를 때 이러한 위임 메서드가 호출되지 않는 이유는 무엇입니까? –