Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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 需要帮助使UIAlert视图具有操作吗_Ios_Objective C_Uialertview - Fatal编程技术网

Ios 需要帮助使UIAlert视图具有操作吗

Ios 需要帮助使UIAlert视图具有操作吗,ios,objective-c,uialertview,Ios,Objective C,Uialertview,这是我正在尝试配置的.m的一部分: 这是我的观点: NSString *message = [NSString stringWithFormat:@"Score %d", _score]; UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Game Over" message:message

这是我正在尝试配置的.m的一部分: 这是我的观点:

NSString *message = [NSString stringWithFormat:@"Score %d", _score];
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Game Over"
                                                     message:message
                                                    delegate:nil
                                           cancelButtonTitle:@"Play Again"
                                           otherButtonTitles:nil];
[av show];
我正在尝试创建上述UIAlertView,因此当我再次单击“播放”时,它会执行以下操作:

[self runAction:[SKAction sequence:@[[SKAction repeatAction:[SKAction sequence:@[[SKAction runBlock:^{

        }], [SKAction waitForDuration:0.05],  [SKAction waitForDuration:0.05]]] count:4], [SKAction runBlock:^{
            _canRestart = YES;
        }]]]];
这是我的。h:

#import <SpriteKit/SpriteKit.h>

@interface MyScene : SKScene

@end

查看
UIAlertViewDelegate
,每当按下警报时就会调用它:

然后在委托方法中(
-(void)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引
):


当按下“确定”按钮时,游戏将重新启动。

为什么您的警报只有一个选择?为什么不能取消警报而不重新播放?请阅读
UIAlertView
的文档。它告诉你所有关于委托和你应该实现的方法。因为我想让它重新启动我的游戏,我使用了vborra的代码,但它说“使用未声明的标识符‘alertView’”。我该怎么办?你是否将委托设置为.h文件?将当前行更改为@interface MyScene:SKScene我已经有了它,我仍然在使用未声明的标识符“alertView”消息
    }], [SKAction waitForDuration:0.05],  [SKAction waitForDuration:0.05]]] count:4], [SKAction runBlock:^{
        _canRestart = YES;
    }]]]];
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Game Over" message:message delegate:self cancelButtonTitle:@"Play Again" otherButtonTitles:nil];
[self runAction:[SKAction sequence:@[[SKAction repeatAction:[SKAction sequence:@[[SKAction runBlock:^{

    }], [SKAction waitForDuration:0.05],  [SKAction waitForDuration:0.05]]] count:4], [SKAction runBlock:^{
        _canRestart = YES;
    }]]]];