菜鸟教程小白 发表于 2022-12-11 20:22:56

objective-c - 如何根据 buttonIndex 使 UIAlertView 不关闭


                                            <p><p>嗨:D 我正在制作一个应用程序,其中有一个 UIAlertView,当 <code>dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated</code> 的 buttonIndex 为 1 时,我不想关闭它,但如果它不是 1 它应该解雇。我怎样才能实现它?谢谢:D</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在这种情况下,您可以实现它的委托(delegate):</p>

<pre><code>- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
</code></pre>

<p>在其正文中,您可以检查 buttonIndex 是否为 1 并采取相应措施</p></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - 如何根据 buttonIndex 使 UIAlertView 不关闭,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7859887/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7859887/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - 如何根据 buttonIndex 使 UIAlertView 不关闭