2013-07-12 15 views
0

我對iOS編程非常陌生,並且正在製作一個簡單的應用程序。第一個UITabBarItem加載一個頁面,但在加載之前有一個標籤。我試圖讓網頁加載後標籤消失,但它不起作用。我相信我需要設置網絡視圖委託,但我不知道如何。網絡視圖完成加載labelname.hidden =是不工作?

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 
+0

爲什麼這麼多帖子開始「我是新來的......」?至少,爲我自己說話,我覺得它很煩人,而且與任何問題無關。這通常也是隱含的這種或那種方式。 – SK9

+0

對不起,只是讓他們明白我沒有經歷過..? –

+0

在你的筆尖中,你有沒有把webview委託連接到所有者? –

回答

1

插入_webPage.delegate = self;調用loadRequest:之前。
您應該修改接口定義到@interface OTFFirstViewController : UIViewController <UIWebViewDelegate>

+2

@OP,因爲您正在使用IBOutlets,只需將代理連接到所有者即可。您將保存一行代碼:) –

+0

我不知道這意味着什麼。抱歉。 –

+0

REEEEEEEEEAAAADD。 – SK9