2016-08-09 2 views
2

내 iOS 애플리케이션에서 UIAlertController를 사용하여 손쉬운 개인 정보 취급 방침을 구현하려고합니다. 법에 따르면 요즘 대부분의 개인 정보 보호 정책처럼 정책을 스크롤 할 수 있어야 허용됩니다.Swift에서 개인 정보 취급 방침 만들기 : 메시지가 맨 아래로 스크롤 될 때까지 UIAlertController 동작 버튼을 비활성화하는 방법

내 자신의 연구에서 UIAlertAction 버튼을 비활성화하고 활성화 할 수 있다고 보았지만 UIAlertController 메시지 본문이 스크롤 된 시점을 식별하는 방법을 알지 못합니다. 맨 아래로 스크롤하는 것은 필수 사항 일 수 있으며 나는 또한 작동 할 수있는 방법을 찾는 데 관심이 있습니다.

UIAlertController

다음은 위의 UIAlertController보고 기본에 내 현재 코드입니다. 다음과 같이

let alertController = UIAlertController(title: "Privacy Policy", message: privacyPolicyString, preferredStyle: UIAlertControllerStyle.Alert) 

let AcceptAction = UIAlertAction(title: "Accept", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction) -> Void in 

    //perform next step in login verification 
}) 

let DeclineAction = UIAlertAction(title: "Decline", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction) -> Void in 

    //User has declined privacy policy. The view resets to standard login state 
}) 

alertController.addAction(AcceptAction) 
alertController.addAction(DeclineAction) 

self.presentViewController(alertController, animated: true, completion: nil) 
+0

버튼 –

답변

0

이 기본 UIAlertController 가능 할 수 있습니다 : - 당신이 아래로 스크롤하면

  1. 이 거짓
  2. 에 유형 UIAlertAction
  3. 설정 enabled의 변수를 만들고, 당신이 이것을 확인하실 수 있습니다 스크롤 위임자 또는 임의의 사용자 정의 방법을 선택한 다음 enabled을 true로 설정하십시오.
  4. 아래에서 가장 중요한 것은 c 송가는 다음과 같습니다 -

    self.actionToEnable = action 
    action.enabled = false 
    

코드 참조 : -

당신이보기의 오프셋 (offset)에 대한 액세스 및 활성화하거나 비활성화 할 수있는 능력을 가지게됩니다 당신이 그것에 대해 자신의 경고보기를 만들 필요가
weak var actionToEnable : UIAlertAction? 

func callbackWhenScrollToBottom(sender:UIScrollView) { 
    self.actionToEnable?.enabled = true 
} 

     let alert = UIAlertController(title: "Title", message: "Long text here", preferredStyle: UIAlertControllerStyle.Alert) 
     let cancel = UIAlertAction(title: "Accept", style: UIAlertActionStyle.Cancel, handler: { (_) -> Void in 

     }) 

     let action = UIAlertAction(title: "Decline", style: UIAlertActionStyle.Default, handler: { (_) -> Void in 

     }) 

     alert.addAction(cancel) 
     alert.addAction(action) 

     self.actionToEnable = action 
     action.enabled = false 
     self.presentViewController(alert, animated: true, completion: nil) 
+0

이것은 좋은 시작입니다! 콜백에서 경고의 스크롤 오프셋을 찾는 방법에 대한 통찰력을 제공 할 수 있습니까? 그리고 내가 그 기능을 어디에서 부를까요? – Danoram

+0

UIAlertController의 계층을 검사했지만 scrollview, textview를 찾을 수 없습니다. 따라서 스크롤 오프셋을 얻을 수 없습니다. 어떤 해결책을 찾았습니까? – pkc456

+0

아니요 아직 불행히도. 나는 아직도 그것을 조사하고있다! – Danoram