0

当我使用alertView下面的代码时,它会向我显示警告

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

这是代码:

    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];
4

2 回答 2

2

如果您使用私有方法(其中addTextFieldWithValue:之一),那么 Apple 很可能会拒绝您的应用程序。您可以使用以下代码段获得相同的结果,由this answer提供,该链接归功于不再工作的链接:

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];
于 2011-11-17T05:33:26.587 回答
1

该方法未记录在案。您必须创建自己的文本字段,然后将其添加到警报视图。

于 2011-11-17T05:30:43.407 回答