开发者

warning: 'UIAlertView' may not respond to '-addTextFieldWithValue:label:'

开发者 https://www.devze.com 2022-12-20 20:25 出处:网络
in my application i was using UIAlertView for login, it contains TextFields, its working perfectly, but i\'m getting a warning when i compile the code, i\'m using iphone SDK 3.0

in my application i was using UIAlertView for login, it contains TextFields, its working perfectly, but i'm getting a warning when i compile the code, i'm using iphone SDK 3.0

code :

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

warning: 'UIAlertView' may not respond to '-addTextFieldWithValue:label:'

txfUserName = [loginAlert textFieldAtIndex:0];

warning: 'UIAlertView' may not respond to '-textFie开发者_运维知识库ldAtIndex:'


This method is private, you should not use it (your app will be rejected). Maybe they removed or renamed it in the latest SDK. For an alternative, see

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


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

all credits to: http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html


You can use http://github.com/enormego/EGOTextFieldAlertView. It gives you those private methods, in a subclass of UIAlertView. This way you don't have to change your code at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消