在用户驳回广告之前防止骚扰?

时间:2017-03-06 12:17:37

标签: ios swift admob segue

我正在将interstital广告整合到我应用中的一些细分中。

问题是中间载荷,然后被segue触发立即排除。

是否有方法暂停功能,直到广告关闭才运行segue?这是我能想到解决这个问题的唯一方法。代码如下:

if ($option1 == $correct_answer && $correct_answer == $single_answer1) {
    $sc_flag = 1; // student's selected correct flag
}
if ($option2 == $correct_answer && $correct_answer == $single_answer1) {
    $sc_flag = 2;
}
if ($option3 == $correct_answer && $correct_answer == $single_answer1) {
    $sc_flag = 3;
}
if ($option4 == $correct_answer && $correct_answer == $single_answer1) {
    $sc_flag = 4;
}
if ($option1 == $correct_answer) {
    $correct_flag = 1; // correct answer
}
if ($option2 == $correct_answer) {
    $correct_flag = 2;
}
if ($option3 == $correct_answer) {
    $correct_flag = 3;
}
if ($option4 == $correct_answer) {
    $correct_flag = 4;
}
if ($option1 == $single_answer1) {
    $actual_flag = 1; // selected option by student
}
if ($option2 == $single_answer1) {
    $actual_flag = 2;
}
if ($option3 == $single_answer1) {
    $actual_flag = 3;
}
if ($option4 == $single_answer1) {
    $actual_flag = 4;
}
?>
<?php if ($sc_flag == 1) {?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(A) <?php echo $option1; ?>
    </label>
<?php } else if ($actual_flag == 1 && $correct_flag != 1) {
    ?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-times" style="color:red;font-size:15px"></i></label>
        <span class="">(A) <?php echo $option1; ?>
    </label>
<?php } else if ($correct_flag == 1) {?>
    <label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:yellow;font-size:15px"></i></label>
        <span class="">(A) <?php echo $option1; ?>
    </label>
<?php } else {?>
    <label style="font-size:14px">
        <span class=""><input type="radio" name="single_question_answer1" value="<?php echo $option1; ?>" ></span> (A) <?php echo $option1; ?>
    </label>
<?php }?><br/><br/>
<?php if ($sc_flag == 2) {?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(B) <?php echo $option2; ?>
    </label>
<?php } else if ($actual_flag == 2 && $correct_flag != 2) {
    ?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-times" style="color:red;font-size:15px"></i></label>
        <span class="">(B) <?php echo $option2; ?>
    </label>
<?php } else if ($correct_flag == 2) {?>
    <label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:yellow;font-size:15px"></i></label>
        <span class="">(B) <?php echo $option2; ?>
    </label>
<?php } else {?>
    <label style="font-size:14px">
        <span class=""><input type="radio" name="single_question_answer1" value="<?php echo $option2; ?>" ></span> (B) <?php echo $option2; ?>
    </label>
<?php }?><br/><br/>
<?php if ($sc_flag == 3) {?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(C) <?php echo $option3; ?>
    </label>
<?php } else if ($actual_flag == 3 && $correct_flag != 3) {
    ?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-times" style="color:red;font-size:15px"></i></label>
        <span class="">(C) <?php echo $option3; ?>
    </label>
<?php } else if ($correct_flag == 3) {?>
    <label style="font-size:14px;background-color:yellow;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(C) <?php echo $option3; ?>
    </label>
<?php } else {?>
    <label style="font-size:14px">
        <span class=""><input type="radio" name="single_question_answer1" value="<?php echo $option3; ?>" ></span> (C) <?php echo $option3; ?>
    </label>
<?php }?><br/><br/>
<?php if ($sc_flag == 4) {?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(D) <?php echo $option4; ?>
    </label>
<?php } else if ($actual_flag == 4 && $correct_flag != 4) {
    ?>
    <label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-times" style="color:red;font-size:15px"></i></label>
        <span class="">(D) <?php echo $option4; ?>
    </label>
<?php } else if ($correct_flag == 4) {?>
    <label style="font-size:14px;background-color:yellow;border:1px solid green;padding:10px" >
        <label class="review-icon"><i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"></i></label>
        <span class="">(D) <?php echo $option4; ?>
    </label>
<?php } else {?>
    <label style="font-size:14px">
        <span class=""><input type="radio" name="single_question_answer1" value="<?php echo $option4; ?>" ></span> (D) <?php echo $option4; ?>
    </label>
<?php }?><br/><br/>

编辑:不起作用的新代码......

@IBAction func closeExerciseDetails(_ sender: Any) {
    if (self.interstitial.isReady) {
        self.interstitial.present(fromRootViewController: self)
        self.interstitial = self.createAd()
    }
    self.performSegue(withIdentifier: "unwindToExercisesSegue", sender: self)
}

1 个答案:

答案 0 :(得分:3)

这是一个代表:

- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial {
}

您可以在此委托中执行segue。