0

ユーザーログイン用のUIAlertView内にユーザーIDとパスワード用の2つのUITextFieldまたはTextBoxを作成する必要があるアプリケーションを作成しています。何かを試しましたが、作成されたテキストフィールドが非常に大きくなり、アラートビュー全体をほぼカバーしています。アラート ビュー内でテキスト フィールドやラベルなどを整理する方法。「ユーザーID」と「パスワード」というラベルに対して小さなテキストフィールドが必要です。では、どうやってそれを行うのですか?私を助けてください。事前にサンクス。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"User Login" message:@"Please Enter the Following \n\n\n\n\n\n\n" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Sign In", nil];


UILabel *lblUserName = [[UILabel alloc] initWithFrame:CGRectMake(20, 70, 85, 21)];
lblUserName.tag =2;
//lblUserName.backgroundColor = [UIColor darkGrayColor];
lblUserName.font = [UIFont systemFontOfSize:15.0];
lblUserName.text = @"User Name:";
lblUserName.textColor=[UIColor whiteColor]; 

//[lblUserName setFont:[UIFont fontWithName:@"TimesNewRomanPS-boldMT" size:8]];
lblUserName.backgroundColor = [UIColor clearColor]; 
[alert addSubview:lblUserName];

UITextField *txtUserName;

//if(txtUserName==nil)
 txtUserName = [[UITextField alloc] initWithFrame:CGRectMake(89, 50, 160, 30)];

txtUserName.tag = 3;
txtUserName.borderStyle = UITextBorderStyleBezel;
txtUserName.textColor = [UIColor whiteColor];
txtUserName.font = [UIFont systemFontOfSize:12.0];
txtUserName.placeholder = @"User ID";
[alert addSubview:txtUserName]; 



alert.tag=3;
[alert show];
[alert release];
4

2 に答える 2

1

iOS5 以降、UIAlertView はアラート スタイル UIAlertViewStyleLoginAndPasswordInput を使用したログイン画面をサポートします。

詳細については、UIAlertView クラス リファレンスを参照してください。

于 2012-08-17T10:06:54.967 に答える
0
 UIAlertView *alert =[UIAlertView alloc] init];
 alert.delegate =self //make sure to add the UIAertViewDelegate in the .h file
 alert.alertViewStyle =UIAlertViewStyleLoginAndPasswordInput;
 alert.message =@"Please login";
 [alert show];
 [alert release];

次に、clickedButtonAtIndex デリゲート メソッドで:

{
   UITextField *username = [alertView textFieldAtIndex:0];
   UITextfield *password = [alertView textFieldAtIndex:1];
   NSLog(@"Username %"@  password %"@,username.text, password.text);
}  
于 2012-08-17T10:58:35.457 に答える