以下是我用於創建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