2016-12-06 57 views
0

當我點擊同意按鈕時,它應該去AgreeCompletionStep,但它去同意不同意步驟。請任何人都可以指出是什麼問題?我有問題,ORKResultPredicate的predicateForConsent函數

let consentTask = ORKNavigableOrderedTask(identifier: String(describing:Identifier.consentTask), steps: [reviewConsentStep, disAgreeStep, completionStep]) 

resultSelector = ORKResultSelector(
    resultIdentifier: String(
     describing: Identifier.consentReviewStep)) 
let predicateAgree = ORKResultPredicate.predicateForConsent(
    with: resultSelector, didConsent: true) 

let agreePredicateRule = ORKPredicateStepNavigationRule(
    resultPredicatesAndDestinationStepIdentifiers: [ 
     (predicateAgree, 
     String(describing: Identifier.consentCompletionStep))]) 

consentTask.setNavigationRule(
    agreePredicateRule, 
    forTriggerStepIdentifier:String(
     describing:Identifier.consentReviewStep)) 

let consentDirectRule = ORKDirectStepNavigationRule(
    destinationStepIdentifier: ORKNullStepIdentifier) 
consentTask.setNavigationRule(
    consentDirectRule, 
    forTriggerStepIdentifier:String(
     describing:Identifier.consentDisagreeStep)) 
+0

則可以反向添加'Rule'這個命令和檢查。 –

+0

所以我將predicateRule上面的directRule移動了,但它不起作用。 – iarpits

回答

0

的問題是,所述resultSelector傳遞給+predicateForConsentWithResultSelector:didConsent:必須提供所需的步驟標識符(stepIdentifier參數)和所期望的簽名標識符(resultIdentifier參數)。

相反的:

let resultSelector = ORKResultSelector(resultIdentifier:String(describing: Identifier.consentReviewStep)) 
let predicateAgree = ORKResultPredicate.predicateForConsent(with: resultSelector, didConsent: true) 

它應該是:

let resultSelector = ORKResultSelector(stepIdentifier: String(describing: Identifier.consentReviewStep), resultIdentifier: signature.identifier) 
let predicateAgree = ORKResultPredicate.predicateForConsent(with: resultSelector, didConsent: true)