2012-09-12 18 views
0

在iOS中,我使用一個文本字段,文本字段ID的長度太長,所以它在文本字段的末尾顯示點。我需要刪除點。我也用過lineBreakMode如何刪除UITextfield中的點?

查看我使用的代碼。

CGSize maximumSize = CGSizeMake(titleListTxtFld.frame.size.width, 1000); //here 1000 for maximum height u can increase this if u want 
CGSize strSize = [titleListTxtFld.text sizeWithFont:titleListTxtFld.font constrainedToSize:maximumSize lineBreakMode:UILineBreakModeClip]; 
CGRect newframe = CGRectMake(0, 0, strSize.width, strSize.height); 
[titleListTxtFld.text drawInRect:newframe 
        withFont:titleListTxtFld.font 
      lineBreakMode:UILineBreakModeClip 
       alignment:UITextAlignmentLeft]; 

請任何人都幫助我。

+0

是否要根據文本更改文本字段的大小或者只是刪除點或僅更改文本的字體以適合它? – lostInTransit

+0

我只是想刪除點。那就夠了 –

+3

爲你的需求使用UITextView –

回答

0

另一種方法(刪除點和剪輯的文本框) -

您可以刪除的UITextField調用點以下代碼

[self.yourTextField becomeFirstResponder]; 

,你也可以隱藏默認鍵盤[如果你使用任何自定義鍵盤]使用下面的代碼

// Hide keyboard for Dial Pad, but show blinking cursor 
UIView *dummyKeyboardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
yourTextField.inputView = dummyKeyboardView; 
[dummyKeyboardView release]; 

但我認爲IlNero的answer對你更好,如果你想顯示的所有文本(不夾)。