Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode 5.1“;预期标识符或;(“错误_Ios_Xcode - Fatal编程技术网

Ios Xcode 5.1“;预期标识符或;(“错误

Ios Xcode 5.1“;预期标识符或;(“错误,ios,xcode,Ios,Xcode,我在一个花括号后出现这个错误。我正在为iOS编写一个应用程序。我是一个初学者,请详细解释。谢谢 - (IBAction)button1:(id)sender; { //error happens here "Expected identifier or "(" "` UIImageView *img1=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"batman.jpg"]];

我在一个花括号后出现这个错误。我正在为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;
不是此错误的原因,但是您不应该在任何方法的末尾使用它,因为它是语句的终点

错误原因

在这里,您可以将
”(“
括号放在类中此方法的上方

- (IBAction)button1:(id)sender;
编译器从类的顶部开始编译。如果出现任何语法错误,编译器将停止编译剩余的代码


因此,很明显,从上述方法开始检查您的代码。并删除额外的
括号,错误将消失。

-(iAction)按钮1:(id)发件人;\n请删除分号“以@Vipul所说的为基础,任何时候你写一个方法时,你都不希望在行尾有一个分号。这是一个objective-c语法的东西。实际上,任何基于c语言的语言都是如此。谢谢!这对我帮助很大。