2011-12-28 39 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