警报视图显示我警告
问题描述:
当我使用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];
答
那种方法无证。您将不得不创建自己的文本字段,然后将其添加到警报视图。
答
如果您使用私有方法(其中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];
+0
感谢PengOne这是工作.. :) –
的可能重复[警告:“UIAlertView中”可能不响应“:标签:-addTextFieldWithValue”( http://stackoverflow.com/questions/2294910/warning-uialertview-may-not-respond-to-addtextfieldwithvaluelabel) – PengOne
并且'-textFieldAtIndex:'找不到(返回类型默认为'id') –
同样,你是使用无证或不存在的方法。检查文档。如果该方法不存在,则会发出警告,Apple可能会拒绝该应用程序。 – PengOne