警告:'UIAlertView'可能无法响应'-addTextFieldWithValue:label:'

时间:2010-02-19 08:29:36

标签: iphone

在我的应用程序中我使用UIAlertView进行登录,它包含TextFields,它工作得很好,但是当我编译代码时我收到警告,我正在使用iphone SDK 3.0

代码:

loginAlert = [[UIAlertView alloc] initWithTitle:@"Enter the User Name and Password" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Login", nil];

[loginAlert addTextFieldWithValue:appDelegate.userName label:@"UserName"];

警告:'UIAlertView'可能无法响应'-addTextFieldWithValue:label:'



txfUserName = [loginAlert textFieldAtIndex:0];

警告:'UIAlertView'可能无法响应'-textFieldAtIndex:'

3 个答案:

答案 0 :(得分:3)

此方法是私有的,您不应该使用它(您的应用将被拒绝)。也许他们在最新的SDK中删除或重命名了它。有关替代方案,请参阅

http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html

答案 1 :(得分:2)

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:testTextField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[myAlertView setTransform:myTransform];
[myAlertView show];
[myAlertView release];

所有积分:http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html

答案 2 :(得分:0)

您可以使用http://github.com/enormego/EGOTextFieldAlertView。它在UIAlertView的子类中为您提供了这些私有方法。这样您就不必更改代码了。