2011-11-17 4 views
0

me montrer quand j'utilise alertView en utilisant le code ci-dessous, il me montre l'avertissementVoir avertissement

warning: Semantic Issue: Method '-addTextFieldWithValue:label:' not found (return type defaults to 'id') 

Voici le code:

UIAlertView *alSave=[[UIAlertView alloc]initWithTitle:@"Save as" message:@"Title the note and click Save" delegate:self cancelButtonTitle:@"save" otherButtonTitles:@"cancel", nil]; 
    NSArray *arr=[noteObj.noteTitle componentsSeparatedByString:@" - "]; 
    app.longClickId = [noteObj.noteId integerValue]; 
    [alSave addTextFieldWithValue:[NSString stringWithFormat:@"%@",[arr objectAtIndex:0]] label:@"Note Name"]; 
    // show me warning at this place 

    textField = [alSave textFieldAtIndex:0]; 
    textField.keyboardType = UIKeyboardTypeAlphabet; 
    textField.keyboardAppearance = UIKeyboardAppearanceAlert; 
    textField.autocorrectionType = UITextAutocorrectionTypeNo; // correction automatically 

    [alSave show]; 
    if (app.NotePopOver!= nil) { 
     [app.NotePopOver dismissPopoverAnimated:YES]; 

    } 
    [alSave release]; 
+1

double possible de [avertissement: « UIAlertView » ne peut pas répondre à « -addTextFieldWithValue: label: »] (http://stackoverflow.com/questions/2294910/warning-uialertview-may-not-respond-to-addtextfieldwithvaluelabel) – PengOne

+0

et '-textFieldAtIndex:' non trouvé (le type de retour par défaut est 'id') –

+0

Encore une fois, vous êtes en utilisant des méthodes non documentées ou inexistantes. Vérifiez la documentation. Si la méthode n'est pas là, un avertissement s'ensuivra et Apple rejettera probablement l'application. – PengOne

Répondre

1

Cette méthode est non documentée. Vous devrez créer votre propre champ de texte, puis l'ajouter à la vue d'alerte.

2

Si vous utilisez une méthode privée (dont addTextFieldWithValue: est un), Apple rejettera probablement votre application. Vous pouvez obtenir le même résultat avec l'extrait suivant, avec la permission de this answer qui crédite un lien ne fonctionne plus:

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; 
[myTextField setBackgroundColor:[UIColor whiteColor]]; 
[myAlertView addSubview:myTextField]; 
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0); 
[myAlertView setTransform:myTransform]; 
[myAlertView show]; 
[myAlertView release]; 
+0

Merci PengOne c'est du travail pour .. :) –