以下是我用于创建AlertView的代码。但Ok按钮不可见。UIAlertView确定按钮不可见
UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Reset Password"
message:@"\n\n" // IMPORTANT
delegate:self
cancelButtonTitle:nil
otherButtonTitles:OTHER_BUTTON_OK, nil];
prompt.tag=RESET_PASSWORD;
txtOldPwd = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];
[txtOldPwd setBackgroundColor:[UIColor whiteColor]];
[txtOldPwd setPlaceholder:@"Old Password"];
[email protected]"";
[prompt addSubview:txtOldPwd];
[txtOldPwd release];
txtNewPwd = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 80.0, 260.0, 25.0)];
[txtNewPwd setBackgroundColor:[UIColor whiteColor]];
[txtNewPwd setPlaceholder:@"New Password"];
[email protected]"";
[prompt addSubview:txtNewPwd];
[txtNewPwd release];
txtConfirmPwd = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 110.0, 260.0, 25.0)];
[txtConfirmPwd setBackgroundColor:[UIColor whiteColor]];
[txtConfirmPwd setPlaceholder:@"Confirm Password"];
[email protected]"";
[prompt addSubview:txtConfirmPwd];
[txtConfirmPwd release];
[prompt show];
[prompt release];
我添加了我所得到的屏幕截图。
更新
我才发现,原来按钮实际上有。戒备高度太少。按钮的一小部分是可见的。我试过this approach,但按钮仍然不可见。虽然警戒的高度增加。
屏幕截图显示该按钮在那里,但您的文本字段正在覆盖它!这就是为什么添加“\ n”已经解决了你正在面临的.. !! – samfisher 2011-12-28 09:22:08