Hello,world!

文科的格调 + 工科的背景 = 爱浪漫的程序媛

创建带文本输入的AlertView(无私有API)

这是篇记录文,对技术细节不感兴趣的同学请绕道,不要说我木有事先提醒啊。

 

以下文字来自某篇博文的评论,博文作者是一位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];

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.