-4

在 .m 文件中添加一些 labelLoading 代码时,我在 Xcode 中遇到错误。希望有人可以帮助我并指出代码中的错误。不要在我学习的时候把我打得太惨。我只是无法克服这个错误。

@interface ViewController ()

@end

@implementation ViewController
@synthesize viewWeb;
@synthesize labelLoading;
@synthesize tqwWeb;
@synthesize blogWeb;
@synthesize eventsWeb;
@synthesize resWeb;
@synthesize homeWeb;

- (void)viewDidLoad

{
  [viewWeb setDelegate:self];
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [labelLoading setHidden:NO];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [labelLoading setHidden:YES];
}


{      **This is where the error Expected identifier or "(" occurs**

[super viewDidLoad];

    NSString *fullURL = @"http://www.rtics.com/DC1/";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [viewWeb loadRequest:requestObj];

[super viewDidLoad];

    NSString *afullURL = @"http://www.rtics.com/DC2";
    NSURL *aurl = [NSURL URLWithString:afullURL];
    NSURLRequest *arequestObj = [NSURLRequest requestWithURL:aurl];
    [tqwWeb loadRequest:arequestObj];


[super viewDidLoad];

    NSString *bfullURL = @"http:/www.rtics.com/DC3/";
    NSURL *burl = [NSURL URLWithString:bfullURL];
    NSURLRequest *brequestObj = [NSURLRequest requestWithURL:burl];
    [blogWeb loadRequest:brequestObj];

[super viewDidLoad];

    NSString *cfullURL = @"https://www.rtics.com/DC4";
    NSURL *curl = [NSURL URLWithString:cfullURL];
    NSURLRequest *crequestObj = [NSURLRequest requestWithURL:curl];
    [eventsWeb loadRequest:crequestObj];

[super viewDidLoad];

    NSString *dfullURL = @"http://www.rtics.com/DC5";
    NSURL *durl = [NSURL URLWithString:dfullURL];
    NSURLRequest *drequestObj = [NSURLRequest requestWithURL:durl];
    [resWeb loadRequest:drequestObj];

[super viewDidLoad];

    NSString *efullURL = @"http://www.rtics.com/";
    NSURL *eurl = [NSURL URLWithString:efullURL];
    NSURLRequest *erequestObj = [NSURLRequest requestWithURL:eurl];
    [homeWeb loadRequest:erequestObj];
}

- (void)viewDidUnload
{
    [self setViewWeb:nil];
    [self setLabelLoading:nil];
    [self setWebView:nil];
    [super viewDidUnload];


}
- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

@end
4

1 回答 1

0

错误之前的行应该有- (void)viewDidLoad,你应该只调用[super viewDidLoad]一次。将您其他中的任何内容移动viewDidLoad到此新方法并删除您的其他 viewDidLoad。

例如:

- (void)viewDidLoad
{      **This is where the error Expected identifier or "(" occurs**

    [super viewDidLoad];

    [viewWeb setDelegate:self];  // Moved from previous viewDidLoad method

    NSString *fullURL = @"http://www.rtics.com/DC1/";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [viewWeb loadRequest:requestObj];

    NSString *afullURL = @"http://www.rtics.com/DC2";
    NSURL *aurl = [NSURL URLWithString:afullURL];
    NSURLRequest *arequestObj = [NSURLRequest requestWithURL:aurl];
    [tqwWeb loadRequest:arequestObj];

    NSString *bfullURL = @"http:/www.rtics.com/DC3/";
    NSURL *burl = [NSURL URLWithString:bfullURL];
    NSURLRequest *brequestObj = [NSURLRequest requestWithURL:burl];
    [blogWeb loadRequest:brequestObj];

    NSString *cfullURL = @"https://www.rtics.com/DC4";
    NSURL *curl = [NSURL URLWithString:cfullURL];
    NSURLRequest *crequestObj = [NSURLRequest requestWithURL:curl];
    [eventsWeb loadRequest:crequestObj];

    NSString *dfullURL = @"http://www.rtics.com/DC5";
    NSURL *durl = [NSURL URLWithString:dfullURL];
    NSURLRequest *drequestObj = [NSURLRequest requestWithURL:durl];
    [resWeb loadRequest:drequestObj];

    NSString *efullURL = @"http://www.rtics.com/";
    NSURL *eurl = [NSURL URLWithString:efullURL];
    NSURLRequest *erequestObj = [NSURLRequest requestWithURL:eurl];
    [homeWeb loadRequest:erequestObj];
}
于 2013-09-13T22:40:46.317 回答