预期的 ':' 词法或预处理器错误 [英] Expected ':' Lexical or Preprocessor error
问题描述
嗯,这应该是一个非常快速和简单的问题.我正在创建一个滚动视图并且我已经完成了所有工作,但是有一个我不明白的错误!就像它只是令人困惑,对我来说没有意义!
Well this should be a pretty quick and easy question. I am creating a scrollview and i have it all done, but there is an error that i just dont understand it! like its just confusing and doesnt make sense to me!
错误://预期的 ':'
THE ERROR: // Expected ':'
视图控制器.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
}
@property (weak, nonatomic) IBOutlet UIScrollView *ScrollView;
@end
ViewController.m
ViewController.m
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self ScrollView setScrollEnabled YES] // Expected ':'
[self ScrollView setContentSize: CGSizeMake(320, 900)]
}
我做了所有这些,它只是说预期的标识符.
I did all of this and it just says expected identifier.
[super viewDidLoad];
[self.ScrollView setScrollEnabled: YES];
[[self.ScrollView setContentSize: CGSizeMake(320, 900)]]; //expected identifier
推荐答案
您似乎缺少一个冒号、几个点和几个分号:
It looks like you are missing a colon, a couple of dots, and a couple of semicolons:
[self.ScrollView setScrollEnabled:YES];
// ^ ^ ^
[self.ScrollView setContentSize:CGSizeMake(320, 900)];
// ^ ^
您需要注意语法中的这些小元素——Objective C 不能容忍偏差.语法错误最糟糕的部分是您经常收到指向错误行的报告.
You need to watch out for these small elements of the syntax - Objective C does not tolerate deviations. The worst part about syntax errors is that you often get a report pointing to a wrong line.
这篇关于预期的 ':' 词法或预处理器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!