Domanda

When I use alertView using below code, it shows me the warning

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

Here is the 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];
È stato utile?

Soluzione

That method is undocumented. You will have to create your own text field and then add it to the alert view.

Altri suggerimenti

If you use a private method (of which addTextFieldWithValue: is one), then Apple will most likely reject your app. You can achieve the same result with the following snippet, courtesy of this answer which credits a no longer working link:

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];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top