网页视图确实完成加载labelname.hidden =是不工作?

时间:2013-07-12 02:57:25

标签: objective-c cocoa-touch

我是iOS编程的新手,正在创建一个简单的应用程序。第一个UITabBarItem加载页面但在加载之前有一个标签。我试图让网页加载后标签消失,但它不起作用。我相信我需要设置Web视图委托,但我不知道如何。

firstcontroller.h

#import <UIKit/UIKit.h>

@interface OTFFirstViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIWebView *webPage;

@property (strong, nonatomic) IBOutlet UILabel *pageLoading;

@end

firstcontroller.m

#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSString *fullURL = @"http://asdf.com";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [_webPage loadRequest:requestObj];
}

- (void)webViewDidFinishLoad:(UIWebView *)_webPage
{
    _pageLoading.hidden = YES;

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

1 个答案:

答案 0 :(得分:1)

在致电_webPage.delegate = self;之前插入loadRequest: 您还应将接口定义修改为@interface OTFFirstViewController : UIViewController <UIWebViewDelegate>