这是篇记录文,对技术细节不感兴趣的同学请绕道,不要说我木有事先提醒啊。
以下文字来自某篇博文的评论,博文作者是一位foreigner,网址已经丢失。
Hi Friends,
This way works without any warnings. We are not using Undocumented calls but creating similar UI.
// Ask for Username and password.
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Twitter Details!" message:@"n n n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
// Adds a username Field
UITextField *utextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
utextfield.placeholder = @"Username";
[utextfield setBackgroundColor:[UIColor whiteColor]];
[alertview addSubview:utextfield];
// Adds a password Field
UITextField *ptextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 80.0, 260.0, 25.0)]; ptextfield.placeholder = @"Password";
[ptextfield setSecureTextEntry:YES];
[ptextfield setBackgroundColor:[UIColor whiteColor]]; [alertview addSubview:ptextfield];
// Move a little to show up the keyboard
CGAffineTransform transform = CGAffineTransformMakeTranslation(0.0, 80.0);
[alertview setTransform:transform];
// Show alert on screen.
[alertview show];
[alertview release];
//...
// Don't forget to release these after getting their values
[utextfield release];
[ptextfield release];