小编How*_*wie的帖子

如何使用UIAlertController

我想在吃豆子游戏我从一些网站上得到了使用此代码,但不得不改变UIAlertViewUIAlertController除了下面的代码有两个错误,我不知道如何解决(我真的很新的节目,觉得这是一个真的新手问题 - 抱歉!)

第一个错误在第4行:选择器没有已知的类方法 alertControllerWithTitle

第二个错误出现在最后一行:没有可见的接口声明选择器 show

- (void)collisionWithExit: (UIAlertController *)alert {

    if (CGRectIntersectsRect(self.pacman.frame, self.exit.frame)) {

        [self.motionManager stopAccelerometerUpdates];

        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Congratulations"
                                                        message:@"You've won the game!"
                                                       delegate:self
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil
                                              preferredStyle:UIAlertControllerStyleAlert];
        [alert show];
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview ios swift uialertcontroller

19
推荐指数
2
解决办法
4万
查看次数

标签 统计

ios ×1

objective-c ×1

swift ×1

uialertcontroller ×1

uialertview ×1