【问题标题】:Error with touchesBegan codetouchesBegan 代码出错
【发布时间】:2014-09-18 19:18:47
【问题描述】:

当我写作时

@implementation GameViewController

-(IBAction)StartGame:(id)sender{

    StartGame.hidden = YES;

    BirdMovement = [NSTimer scheduledTimerWithTimeInterval:0.05
    target:self selector:@selector(BirdMoving) userInfo:nil repeats:YES];

}

-(void)BirdMoving{

    Bird.center = CGPointMake(Bird.center.x, Bird.center.y - BirdFlight);

    BirdFlight = BirdFlight - 5;

    if (BirdFlight < -15) {
        BirdFlight = -15;

        if (BirdFlight > 0) {
            Bird.image = [UIImage imageNamed:@"3.png"];

        }

        if (BirdFlight < 0) {
            Bird.image = [UIImage imageNamed:@"4.png"];
        }

}


-(void)touchesBegan:(NSSet *)touches withEvent: (UIEvent *)event{

    BirdFlight =30;

}

它说我使用了一个未声明的标识符touchesBegan: 请帮帮我:)

【问题讨论】:

  • 您需要将代码缩进四个空格才能在 stackoverflow 上正确格式化。

标签: ios iphone xcode5 touchesbegan


【解决方案1】:

您忘记了 BirdMoving 方法中 if (BirdFlight &lt; -15) 语句的右大括号 (})。

在 Xcode 中,选择“编辑”>“全选”(或按 A)。然后选择 Editor > Structure > Re-Indent(或按 controlI)。这将使问题显而易见。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 2014-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多