views:

17

answers:

1

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.)

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];

}

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

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

A: 

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

Jake
I connected the IBOutlet to a function in the ViewController.m file, and then to the File's Owner in the .xib file so that the button does what it's supposed to do when it's enabled. But I don't know how to hook a variable up to a button.
Carter Fort
In your ViewController.h file add:- (IBOutlet)UIButton *randomButton;Then in interface builder drag a connection from the 'File's Owner' (I'm assuming you've set ViewController as the owner of the .xib) to the button you want to enable.
Jake
Excellent! That worked. Thanks so much.
Carter Fort