预期标识符或'('错误

时间:2013-12-11 16:00:49

标签: objective-c uiwebview uiscrollview

我是一名高中生。我完全是新编码,我有一个简短的课程,我选择尝试为我的学校创建一个应用程序。我已经成功完成了大部分编码工作,但我遇到了连续错误,预期的标识符或'('。我在互联网上搜索过,而且我还没有找到解决错误的方法。

所以,我已经完成了两个单独的代码,我正在尝试将它们复制并粘贴在一起。并出现相同的错误。

错误:预期的标识符或'('

@interface ViewController()
<UIWebViewDelegate>

@end

@implementation ViewController
@synthesize webView;

- (void)viewDidLoad
{
[super viewDidLoad];
webView.delegate = self;
NSURL *url = [NSURL URLWithString:@"https://twitter.com/u_bett"];
NSURLRequest *urlrequest = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlrequest];

}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request            navigationType:(UIWebViewNavigationType)navigationType
{
 if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
    return NO;
}

return YES;
}
{               //exected identifier or '('
[self.ScrollView setScrollEnabled: YES];
[self.ScrollView setContentSize: CGSizeMake(320, 900)];
}




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

- (IBAction)Twitter:(id)sender {NSURL *myURL = [NSURL         URLWithString:@"https://twitter.com/u_bett"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];

[webView loadRequest:myRequest];
}

- (IBAction)Facebook:(id)sender {
NSURL *myURL = [NSURL URLWithString:@"https://www.facebook.com/BettSchools"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];

[webView loadRequest:myRequest]; }

编辑: 我按照你的说法做了,它在代码的BOOL部分给了我一些错误。如下所示。     }

  - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request       navigationType:(UIWebViewNavigationType)navigationType    

//Expected ';' after expression

//use of undeclared identifier 'request'
 {
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
    return NO;
}

return YES;
}

1 个答案:

答案 0 :(得分:6)

您拥有任何函数之外的代码块:

{               //exected identifier or '('
[self.ScrollView setScrollEnabled: YES];
[self.ScrollView setContentSize: CGSizeMake(320, 900)];
}

您可能偶然删除了方法定义