-3 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]; }
Run Code Online (Sandbox Code Playgroud)
编辑:我按照你的说法做了,它在代码的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;
}
Run Code Online (Sandbox Code Playgroud)
您有任何函数之外的代码块:
{ //exected identifier or '('
[self.ScrollView setScrollEnabled: YES];
[self.ScrollView setContentSize: CGSizeMake(320, 900)];
}
Run Code Online (Sandbox Code Playgroud)
您可能偶然删除了方法定义
| 归档时间: |
|
| 查看次数: |
376 次 |
| 最近记录: |