2012-02-24 99 views
0

我寫過這段代碼。當我點擊文本字段時,鍵盤不會出現。UIText字段調整大小

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    if (textField==urlTxtFld) { 

     CGRect newBounds = urlTxtFld.bounds; 
     GoogleTxtFld.hidden=YES; 
     //[urlTxtFld setFrame:CGRectMake(0, 0, 320, 40)]; 
     newBounds.size.width = 320; //whatever you want the new width to be 
     [UIView beginAnimations:nil context:nil]; 
     urlTxtFld.bounds = newBounds; 
     [UIView commitAnimations]; 
    }return YES; 
} 

回答

0

的問題是,textField從其委託要求(如果您已經正確設置)「我應該開始編輯?」 [該方法將被調用-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField。但是你並沒有說什麼,也沒有,也沒有,所以它變得困惑,並決定保持退出(通過不顯示鍵盤)。

要顯示鍵盤,您需要在此委託方法中返回'YES'。