2011-12-28 86 views
0

以下是我用于创建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]; 

我添加了我所得到的屏幕截图。

enter image description here

更新

我才发现,原来按钮实际上有。戒备高度太少。按钮的一小部分是可见的。我试过this approach,但按钮​​仍然不可见。虽然警戒的高度增加。

+0

屏幕截图显示该按钮在那里,但您的文本字段正在覆盖它!这就是为什么添加“\ n”已经解决了你正在面临的.. !! – samfisher 2011-12-28 09:22:08

回答

3

增加\ n确定

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

enter image description here

+0

非常感谢。它在第一个工作。 – Nitish 2011-12-28 08:50:09

0

更新您的代码,在这些线路上:

cancelButtonTitle:OTHER_BUTTON_OK 
otherButtonTitles:nil]; 
+0

还没有。 – Nitish 2011-12-28 07:39:22

0

干草尼蒂什你可以用这个代码尝试:

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

我希望它无线我会工作。如果需要澄清,请告诉我。

+0

我认为它不起作用检查一次 – 2011-12-28 07:54:16

+0

它工作Nag_iphone。在我所有的项目中,我都以这种方式使用。只要放下我所给予的。并让我知道发生了什么 – sandy 2011-12-28 07:59:15

+0

我使用u代码后也得到相同的输出,但改变代表笏造成区别... – 2011-12-28 08:05:42