我正在創建一個應用程序,我需要在UIAlertView中爲用戶登錄名創建兩個UITextField或TextBox用戶ID和密碼。我嘗試了一些東西,但是在這裏創建的textfield變得非常大,幾乎覆蓋了整個警報視圖。請有人幫助我如何組織警報視圖內的文本框和標籤等。我需要 - 應該有一個標籤爲「用戶ID」和「密碼」的小文本框。那麼該怎麼做?請幫幫我。提前Thanx。如何在UIAlertView中爲用戶標識和密碼添加uitextfield?
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];