2013-03-04 2 views
1

KKLockscreen보기 컨트롤러를 구현했으며 인앱 설정 컨트롤러 내에서 올바르게 작동합니다. 암호를 설정하고 변경할 수 있습니다.AppDelegate에서 화면 잠금 컨트롤러를 호출 할 수 없습니다.

appdelegate에서 화면보기를 잠그는 것이 문제가 있습니다. 위임 .h 파일을 추가하고 .m 파일에서보기 컨트롤러를 가져 왔습니다. 아직도 로크 스크린을 부르지 않을거야. 어떤 도움?

아래 코드는 제 코드입니다.

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { 
     KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; 
     vc.mode = KKPasscodeModeEnter; 
     vc.delegate = self; 

     dispatch_async(dispatch_get_main_queue(),^ { 
      UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; 

      if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
       nav.modalPresentationStyle = UIModalPresentationFormSheet; 
       nav.navigationBar.barStyle = UIBarStyleBlack; 
       nav.navigationBar.opaque = NO; 
      } else { 
       nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor; 
       nav.navigationBar.translucent = _navigationController.navigationBar.translucent; 
       nav.navigationBar.opaque = _navigationController.navigationBar.opaque; 
       nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle; 
      } 

      [_navigationController presentModalViewController:nav animated:NO]; 
     }); 

    } 
} 

답변

0

난 내 코드를 확인하고는, 나중에 노력하고 있지만이 줄을 여기 펜촉 이름을 부여하지 않은 내가 그것을보기를 표시되지 않는 이유 때문일 수 있습니다 주었다. KKPasscodeViewController *의 VC = [KKPasscodeViewController ALLOC] initWithNibName : 닐 번들 : 닐]

-(void)applicationDidBecomeActive:(UIApplication *)application { 
RootViewController *vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; 

dispatch_async(dispatch_get_main_queue(),^ { 
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; 

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
     nav.modalPresentationStyle = UIModalPresentationFormSheet; 
     nav.navigationBar.barStyle = UIBarStyleBlack; 
     nav.navigationBar.opaque = NO; 
    } else { 
     nav.navigationBar.tintColor = navigationController.navigationBar.tintColor; 
     nav.navigationBar.translucent = navigationController.navigationBar.translucent; 
     nav.navigationBar.opaque = navigationController.navigationBar.opaque; 
     nav.navigationBar.barStyle = navigationController.navigationBar.barStyle; 
    } 

    [navigationController presentModalViewController:nav animated:NO]; 
}); 

} 난 다음 사용해야한다

+0

? KKPasscodeViewController * vc = [[KKPasscodeViewController alloc] initWithNibName : @ "KKPasscodeViewController"번들 : nil]; 하지만 작동하지 않습니다. 죄송합니다. 나는 어느 펜촉 이름을 쓸지 모르겠다. – Kalaichelvan

+0

두 가지 질문이 있습니다. 1> 귀하의보기 컨트롤러가 ipad 버전 또는 iphone 버전에 표시되지 않습니다? 2> if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) true를 반환합니까? 컨트롤이 코드에 포함되는지 여부 –

+0

1. iPhone 및 iPad 버전에서는 표시되지 않습니다. 2. 원래 KKLockscreen에는 데모 앱과 잘 작동합니다. 나는 ([[KKPasscodeLock sharedLock] isPasscodeRequired]) true를 반환 할 때 컨트롤이 코드로 이동한다는 사실을 믿는다. 사실 데모 앱의 코드를 내 앱에 통합하고 있습니다. 설정 패널이 훌륭하게 작동합니다. 단지 그것이 appdelegate에서 호출되지 않고 있다는 것입니다. 나는 스토리 보드를 사용하고있다. KKPasscodeViewController는 코드로 구성됩니다. 스토리 보드에는 구현되지 않았습니다. 문제가 될 수 있습니까? – Kalaichelvan