使用 webViewDidFinishLoad 启用/禁用按钮 [英] Enable/Disable button using webViewDidFinishLoad

查看:30
本文介绍了使用 webViewDidFinishLoad 启用/禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用,我需要防止 UIButton 在页面加载完成之前可用(它使用的资源在页面完全加载之前可能不在页面上).

I'm working on an iOS app, and I need to prevent a UIButton from being usable until the page has finished loading (it uses resources that might not be on the page until it has loaded completely).

现在,我已禁用 Interface Builder 中的按钮,并尝试在 webViewDidFinishLoad 函数中使用 setEnabled.这是它的样子:

Right now, I've disabled the button in Interface Builder and am trying to use setEnabled in the webViewDidFinishLoad function. Here's what it looks like:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [activityIndicator stopAnimating];

 [randomButton setEnabled:YES];

}

activityIndi​​cator 停止动画并按预期隐藏,所以我知道页面正在完全加载.但是,该按钮仍处于禁用状态.

The activityIndicator stops animating and hides as expected, so I know the page is loading fully. However, the button remains disabled.

如何在 webView 加载完成后启用该按钮?

How can I enable that button after the webView finishes loading?

推荐答案

您确定已将 'randomButton' 变量连接到 .xib 文件中的实际按钮吗?

Are you sure you've hooked up the 'randomButton' variable to the actual button in your .xib file?

这篇关于使用 webViewDidFinishLoad 启用/禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆