2010-04-22 5 views
0

다른 UIView가있는 UIView가 있습니다. . 내가 키보드 블록 내보기를 기입 할 때 내부의 UIView에 나는 사용자가 입력하고자하는 텍스트 상자가 :내보기를 차단하는 키보드

의 UIViewController는이 다음

containerView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
self.view=containerView; 
//The apropriate releases etc are further on... 

나는 그것의를 터치하면 키보드가 예상대로 나타나지만 채우려는 텍스트 상자를 차단합니다. 어떻게 뷰를 위로 밀어 올릴 수 있습니까?

rect = CGRectMake(70.0f, 20.0f, 100.0f, 27.0f); 
cf = [self createTextField_Rounded:rect holder:@"+ve"]; 
[sv addSubview:cf]; 

그래서 CF 가까이 될 일이 :

정면에서 전면보기

OptionsFront * fv = [[OptionsFront alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
[containerView addSubview:frontView]; 

는 하위 뷰

SV에서
CGRect bounds = CGRectMake(0.0f, 210.0f, 280.0f, 130.0f); 
sv = [[UIView alloc] initWithFrame:bounds]; 
[self addSubview:sv]; //added to frontView 

는 botton을 근처에있는 텍스트 상자입니다 페이지 하단 나는 그것을 선택할 때 전체 디스플레이가 위로 움직일 것이라고 예상했지만, 키보드는 단지 위로 올라가서 막았습니다.

어떻게해야합니까?

부록 :

- (UITextField *)createTextField_Rounded:(CGRect) frame holder:(NSString *) ph 
{ 
UITextField *returnTextField = [[UITextField alloc] initWithFrame:frame]; 
returnTextField.borderStyle = UITextBorderStyleRoundedRect; 
    returnTextField.textColor = [UIColor blackColor]; 
returnTextField.font = [UIFont systemFontOfSize:17.0]; 
returnTextField.delegate = self; 
returnTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 
returnTextField.returnKeyType = UIReturnKeyDone; 

returnTextField.clearButtonMode = UITextFieldViewModeWhileEditing; 

return returnTextField; 
} 

답변

3

당신이 텍스트 필드를 이동해야합니다.

- (void)textFieldDidBeginEditing:(UITextField *)textField { 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.3]; 
    textField.superview.frame = CGRectMake(0.0f, 100.0f, 280.0f, 130.0f); // experiment with frame size 
    [UIView commitAnimations]; 
} 

을 당신은 textFieldDidEndEditing:

+0

덕분에 다시 이동하려는 것이다 : 당신의 UITextField 대리자 (메모리에서) 같은 것을 구현! 매우 우아한 솔루션! –

관련 문제