2012-07-06 15 views
2

我努力讓自己在Xcode的一場比賽,我想提醒消息彈出當用戶達到一定的分數,說100分的觸發條件。當視圖加載時,我已經獲得了代碼以提醒用戶。但是我想讓警報消息只在玩家獲得某個分數時才顯示。製作的警報視圖彈出當達到

本場比賽的進球是這樣的:每個玩家點擊/點擊一個按鈕時,他得到一分,因此他拍打100次後得到100分。

這裏是使警報消息彈出視圖時加載了代碼:

- (void)viewDidLoad 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tile" message:@"This is the message" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; 

    [alert show]; 
    [alert release]; 

    [super viewDidLoad]; 
} 

回答

2

在您的按鈕操作調用方法來顯示警報點時達到100

例如剛纔複製的是直的.M,但我得到了像5個錯誤

- (void) buttonAction { 
    point++; 
    if(point == 100) 
     [self showAlert]; 
} 

- (void) showAlert { 

     UIAlertView *alert = [[UIAlertView alloc] 

          initWithTitle:@"Tile" 
          message:@"This is the message" 
          delegate:nil 
          cancelButtonTitle:@"Dismiss" 
          otherButtonTitles:nil]; 

     [alert show]; 
     [alert release]; 
} 
+0

是喜是有可能你能告訴我如何將它歸功於 – Picm 2012-07-06 11:46:30

+0

我想我可能已經整理了其他錯誤,它只是用1個故障出現現在[警報發佈]; ARC禁止「發佈」的顯式消息發送? – Picm 2012-07-06 11:51:34

+0

也...'釋放'不可用:在自動參考計數模式中不可用?那只是爲發行和方式由於使用圓弧釋放我真的很感激這哥們 – Picm 2012-07-06 11:58:20

0
  1. 不要把你的警報在viewDidLoad中,而不是把它放在一個方法調用的任何名稱。
  2. 在您的按鈕操作事件處理程序,當計數達到100,叫什麼名字上方顯示警報的方法。