2013-10-10 58 views
-1

然后在我的应用程序中,用户必须强制输入数据。 其中一些数据由NSInteger和一些考虑了点击显示数字的按钮的标签控制。如果UILabel等于空,则显示UiAlertView

现在我需要当用户按下按钮“保存”,如果标签不包含数字,UIAlertView警告他缺少的字段。

下面我试图做到这一点..有了标签,你可以使用这个系统吗?

- (IBAction)FFSalvaDati_ConvalidaEsame:(id)sender { 

    if (!FFVotazioneLabel == 0 || FFCFULabel == 0) { 
     UIAlertView *FFAlertConvalidaEsameError = [[UIAlertView alloc] initWithTitle:@"ATTENZIONE" message:@"Per procedere con la convalidazione è necessario inserire il numero dei CFU ottenuti per questo esame e la sua Votazione. \n \n Senza questi dati non ci è possibile calcolare la tua media attuale!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [FFAlertConvalidaEsameError show]; 

    } else { 


} 

回答

1

您需要检查标签的文字。请考虑再次检查代码,因为我没有自己测试它。这样做:

- (IBAction)FFSalvaDati_ConvalidaEsame:(id)sender { 

if ([FFVotazioneLabel.text isEqualToString:@""] || [FFCFULabel.text isEqualToString:@""]) { 
    UIAlertView *FFAlertConvalidaEsameError = [[UIAlertView alloc] initWithTitle:@"ATTENZIONE" message:@"Per procedere con la convalidazione è necessario inserire il numero dei CFU ottenuti per questo esame e la sua Votazione. \n \n Senza questi dati non ci è possibile calcolare la tua media attuale!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
    [FFAlertConvalidaEsameError show]; 

} else { 


} 
+0

完美Balestra!谢谢你非常明确的答案! – kAiN

相关问题