4
我想在一個Pacman遊戲中使用這段代碼,我從某個網站上得到,但不得不將UIAlertView更改爲UIAlertController,除了下面的代碼有兩個錯誤,我不知道如何解決(我真的新的節目,覺得這是一個非常新手問題 - 對不起!!)如何使用UIAlertController
第一個錯誤是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];
}
}
'AlertView'在iOS的9 depricated所以不是必須用'UIAlertController'有更多的選擇。 – vaibhav
[對你有用的鏈接](https://www.google.co.in/?gws_rd=ssl#q=uialertview+deprecated+ios+9+),搜索一下:) – vaibhav