2015-04-19 31 views
0

我目前編碼的應用程序有一個允許用戶在數據庫中發送評論的uibutton。Alertview Void Alert3 clickedButtonAtIndex不叫

我在我的按鈕中創建了很多條件來顯示一些UialertView,如果有些字段是空的。

我也用下面的方法: - (空)myAlert3:(UIAlertView中*)myAlert3 didDismissWithButtonIndex:(NSInteger的)buttonIndex

,但是當我把它,我沒有反應,沒有日誌。 我讀了幾篇文章,但沒有一篇和我一起工作。

這是我的代碼:

-(IBAction)addData:(id)sender{ 

///////////////////////////ALERTE SI LE PSEUDO/COMMENTAIRE EST VIDE//////////////////////////////////////////// 

if ((![_pseudo.text length]) || (![_pseudo.text length])) 
{ 

    UIAlertView *myAlert1 = [[UIAlertView alloc]initWithTitle:@"Alerte"message:@"Merci de renseigner le Pseudo" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles: nil]; 
    [myAlert1 show]; 
} 

else if ((![_comment.text length]) || (![_comment.text length])) 
{ 

    UIAlertView *myAlert2 = [[UIAlertView alloc]initWithTitle:@"Alerte"message:@"Merci d'écrire votre commentaire" delegate:nil cancelButtonTitle:@"Okay " otherButtonTitles: nil]; 
    [myAlert2 show]; 

} 
///////////////////////////FIN ALERTE SI LE PSEUDO/COMMENTAIRE EST VIDE//////////////////////////////////////////// 

///////////////SI PSEUDO EST SUPERIEUR A 3 ET COMMENTAIRE A 10 ON EXECUTE LA METHODE/////////////////////////////// 
else if (_pseudo.text.length > 3 && _comment.text.length > 10) 
{ 



    //Message alerte pour confirmation envoie 
    UIAlertView *myAlert3 = [[UIAlertView alloc] initWithTitle:@"Confirmation" message:@"En appuyant sur OUI vous acceptez de façon inconditionnelles les termes EULA d'Apple" delegate:self cancelButtonTitle:@"Non" otherButtonTitles:@"Oui", nil]; 
    [myAlert3 show]; 


} 
} 

和方法:

- (void)myAlert3:(UIAlertView *)myAlert3 didDismissWithButtonIndex:(NSInteger)buttonIndex 

{ 
if (buttonIndex == 0) 

{  NSLog(@"button no"); 
    _pseudo.hidden=NO; 
    _comment.hidden=NO; 
} 
if (buttonIndex == 1) 
{ 
    NSLog(@"button yes"); 
    _pseudo.hidden=YES; 
    _comment.hidden=YES; 
    //_up.hidden=YES; 

} 
} 

我也試過willDismissWithButtonIndex和clickedButtonAtIndex實現方法具,但沒有工作。

感謝的

+0

Helpp:(((請 – f1rstsurf

回答

3

我認爲你的錯誤是在alertview委託方法的名稱。

你不得不使用:的

- (void)alertView:(UIAlertView *)myAlert3 didDismissWithButtonIndex:(NSInteger)buttonIndex 

代替:

- (void)myAlert3:(UIAlertView *)myAlert3 didDismissWithButtonIndex:(NSInteger)buttonIndex 

您可以更改的參數的名稱,但如果你改變了委託方法的名稱,該代碼將無法正常工作。

+0

感謝的你很:d – f1rstsurf

相關問題