2012-07-14 32 views
0

我創建了iOS設備,但是,imagee一個應用程序下面我有一些錯誤 enter image description hereUIAlertView中代碼中的錯誤

,你可以看到有所有相同的,但我只讓他們錯誤意義上,我加入對於鏈接(蘋果,谷歌,雅虎的代碼,

IM不肯定什麼出了問題,但我真的很感激,如果你能幫助,告訴我什麼,我需要改變,以阻止他們的錯誤。


正如你所看到的這裏僅僅是在節目之下,報警代碼,但我有Xcode中其他10我只是不想佔用所有的空間,但我已經將它們命名爲像

showAlertOO showAlert1 showAlert2 showAlert3 showAlert4 showAlert5 showAlert6 showAlert7 showAlert8 showAlert9

,如果你明白我的意思

- (void) showAlert { 

     UIAlertView *alert = [[UIAlertView alloc] 

           initWithTitle:@"hello" 
           message:@"whats you name" 
           delegate:nil 
           cancelButtonTitle:@"Dismiss" 
           otherButtonTitles:@"apple", @"google" , @"yahoo", nil]; 



     [alert show]; 

好吧,這是我添加的代碼讓我的按鈕工作,然後這就是他們創建錯誤。下面

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ 

if (buttonIndex == 1) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com/uk"]]; 
     } 
    if (buttonIndex == 2) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; 
    } 
     if (buttonIndex == 3) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.yahoo.com"]]; 
     } 

所有的代碼是好的,我沒有錯誤,在這裏我只是想你們看到設置我有

-(IBAction)plus { 
     counter=counter + 1; 
     count.text = [NSString stringWithFormat:@"%i",counter]; 
     if(counter == 100) 
      [self showAlert]; 
     if(counter == 500) 
      [self showAlert00]; 
     if(counter == 1000) 
      [self showAlert1]; 
     if(counter == 2500) 
      [self showAlert2]; 
     if(counter == 5000) 
      [self showAlert3]; 
     if(counter == 7500) 
      [self showAlert4]; 
     if(counter == 10000) 
      [self showAlert5]; 
     if(counter == 15000) 
      [self showAlert6]; 
     if(counter == 20000) 
      [self showAlert7]; 
     if(counter == 25000) 
      [self showAlert8]; 
     if(counter == 30000) 
      [self showAlert9]; 
     if(counter == 35000) 
      [self showAlert10]; 
    } 



    -(IBAction)zero { 
     counter=0; 
     count.text = [NSString stringWithFormat:@"%i",counter]; 
    } 




    - (void)viewDidLoad { 
     counter=0; 
     count.text = @"0"; 
      [super viewDidLoad]; 

    } 

非常感謝您的寶貴時間。

回答

1

在實際使用它們之前,您是否聲明瞭選擇器的showAlert'...'showAlert10'? 如果沒有,你可以聲明他們在一個私人類別(在.m文件的頂部)。

順便說一下...我強烈建議您使用描述性名稱,而不是'showAlert5'。這最終可以爲你節省一些時間,而不僅僅是爲了這個,我的意思是,在你的代碼中的任何地方。

+0

好的感謝您的建議我如何聲明他們然後抱歉它只是我不是最好的編碼器lol – Picm 2012-07-14 15:09:24

+0

這只是一個建議,沒有後顧之憂!請讓我知道如果你仍然有麻煩! – 2012-07-14 15:13:16

+0

好吧,我仍然有同樣的錯誤哥們,所以我想我有麻煩! – Picm 2012-07-14 15:15:36