简体   繁体   中英

UIAlertView Ok button not visible

Following is the code I am using to create an AlertView. But the Ok button is not visible.

 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];  

I am adding a screenshot of what I am getting.

在此处输入图片说明

Update

I just discovered that button is actually there. Height of Alert is too less. A very little portion of button is visible. I tried this approach but the button is still not visible. Although the height of alert increases.

increase the \\n ok

UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Reset Password" 
                                                     message:@"\n\n\n\n\n" // IMPORTANT
                                                    delegate:self 
                                           cancelButtonTitle:nil 
                                           otherButtonTitles:@"ok", nil];

在此处输入图片说明

update your code on these lines:

cancelButtonTitle:OTHER_BUTTON_OK 
otherButtonTitles:nil];

hay Nitish you can try with this code:

UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Reset Password"
                          message:@"\n\n" 
                          delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil];

I hope It will work. Let me know if any clarification needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM