菜鸟教程小白 发表于 2022-12-13 02:44:34

iphone - 在 UIAlertview ios 运行时添加确定按钮


                                            <p><p>我在调用 Web 服务时使用进度指示器 View 调用警报。我正在设置这样的警报 View :</p>

<pre><code>    ;
self.alertView = [ initWithTitle:@&#34;Sending Login Request..&#34;
                                       message:@&#34;\n&#34;
                                    delegate:self
                           cancelButtonTitle:nil
                           otherButtonTitles:nil];

self.activityIndicatorView = [ initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityIndicatorView.center = CGPointMake(139.5, 75.5); // .5 so it doesn&#39;t blur
;
;
;
</code></pre>

<p>稍后如果登录失败,我想将“确定”按钮放在警报 View 上,而不关闭 self.alertView,并再次显示 self.alertView 的新实例。类似这样的事情:</p>

<pre><code>if (isThereErrorFromJsonResp) {
    ;
    ;
    self.activityIndicatorView = nil;
    ;
    //here i want to show ok button how?
    return;
}
</code></pre>

<p>那么我应该如何设置确定按钮呢?
有什么建议吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在获得响应时删除警报并显示这样的新警报实例</p>

<pre><code>;
self.alertView = [ initWithTitle:isThereErrorFromJsonResp
                                       message:@&#34;\n&#34;
                                    delegate:self
                           cancelButtonTitle:@&#34;OK&#34;
                           otherButtonTitles:nil];
;
</code></pre>

<p><strong>解决方案</strong></p>

<p>好的,试过了,明白了</p>

<p>使用</p>

<pre><code>    ;
    ;
    ;
</code></pre>

<p>这会将按钮添加到警报 View </p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 在 UIAlertview ios 运行时添加确定按钮,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/16857802/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/16857802/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 在 UIAlertview ios 运行时添加确定按钮