当我使用以下代码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];
答案 0 :(得分: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];
答案 1 :(得分:1)
该方法没有记录。您必须创建自己的文本字段,然后将其添加到警报视图。