0

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

第一个控制器.h

#import <UIKit/UIKit.h>

@interface OTFFirstViewController : UIViewController

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

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

@end

第一个控制器.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
4

1 回答 1

1

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

于 2013-07-12T03:12:00.967 回答