Xcode 5.1 "Expected identifier or " ( " " 错误



我在花括号后得到这个错误。我正在为iOS编写一个应用程序。我是一个初学者,请详细解释。谢谢

- (IBAction)button1:(id)sender;
{ //error happens here "Expected identifier or "(" "`
            UIImageView *img1=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"batman.jpg"]];
                 img1.frame=CGRectMake(100, 75, 125, 351)
                 [self.view addSubview:img1];
          img1.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
          [UIView animateWithDuration:0.4
                                       delay:0.0
                                     options:UIViewAnimationOptionCurveEaseIn
                                  animations:^{
                                      img1.transform =    CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI/10), 1.7,1.7);
                                  } completion:^(BOOL finished) {
               }];
           [img1 startAnimating];
}

错误是因为您在类中放错了"("字符。

- (IBAction)button1:(id)sender;

;不是导致此错误的原因,但不应在任何方法的末尾使用它,因为它是语句的终点。

错误原因

在这里,您已经将"("括号放在了类中该方法的上方。

编译器从类的顶部开始编译。若出现任何语法错误,编译器将停止编译剩余的代码。

因此,很明显,从上面这个方法开始检查代码。去掉多余的(括号,错误就会消失。

相关内容

最新更新