2010-05-21 136 views
3

我有一個帶有文本框的UIAlertView,顯示默認值和兩個按鈕,一個用於取消,另一個用於確認。我想要做的是,當彈出警報視圖時,默認值將突出顯示,以便用戶可以覆蓋整個值,而不是手動刪除它。如何在UIAlertView文本域內自動突出顯示文本

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Title" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue",nil]; 
[alert addTextFieldWithValue:@"87893" label:@"value"]; 
UITextField *textField = [alert textField]; 
campoTexto.highlighted = YES; 
campoTexto.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 
[alert show]; 
[alert release]; 

}

出於某種原因,沒有爲文本框高亮顯示的屬性,但它似乎沒有工作,也沒有類文檔中該屬性的蹤跡。

回答

1

我有類似的情況。我想提示用戶輸入一個新值,但是,我不想讓原始值消失,但我也不希望文本附加到該值。

我結束了通話

[alertView show]; 
[textField selectAll:self]; 

有一件事你可能也看出來是要設置鍵盤類型,並強調對campoTexto這是不是你從警報視圖獲取文本字段。