以下是我用来创建AlertView的代码。但是Ok按钮不可见。
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"];
txtOldPwd.text=@"";
[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"];
txtNewPwd.text=@"";
[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"];
txtConfirmPwd.text=@"";
[prompt addSubview:txtConfirmPwd];
[txtConfirmPwd release];
[prompt show];
[prompt release];
我正在添加我所获得的截图。
更新
我刚刚发现按钮实际上就在那里。警报的高度太低了。只有一小部分按钮可见。我试过this approach,但按钮仍然不可见。虽然警报的高度增加了。
答案 0 :(得分:3)
增加\ n ok
UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Reset Password"
message:@"\n\n\n\n\n" // IMPORTANT
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"ok", nil];
答案 1 :(得分:0)
在以下行中更新您的代码:
cancelButtonTitle:OTHER_BUTTON_OK
otherButtonTitles:nil];
答案 2 :(得分:0)
hay Nitish你可以试试这段代码:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Reset Password"
message:@"\n\n"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
我希望它会奏效。如果需要任何澄清,请告诉我。