添加滾動視圖中的文本字段的設置及標籤所有textfield.Than把下面的代碼,你必須application.You需要輸入文本框,你按你的要求的位置。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// Begin animations to move TextFields into view.
if (textField.tag == 1) {
[UIView beginAnimations: @"moveField" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self.scrlview.frame = CGRectMake(0,30,320,357);
[UIView commitAnimations];
textfield2.hidden=YES;
textfield3.hidden=YES;
textfield4.hidden=YES;
}
else if(textField.tag == 2)
{
[UIView beginAnimations: @"moveField" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self.scrlview.frame = CGRectMake(0,30,320,357);
[UIView commitAnimations];
textfield1.hidden=YES;
textfield3.hidden=YES;
textfield4.hidden=YES;
}
else if(textField.tag == 3)
{
[UIView beginAnimations: @"moveField" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self.scrlview.frame = CGRectMake(0,25,320,357);
[UIView commitAnimations];
textfield1.hidden=YES;
textfield2.hidden=YES;
textfield4.hidden=YES;
}
else if(textField.tag == 4)
{
[UIView beginAnimations: @"moveField" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self.scrlview.frame = CGRectMake(0,20,320,357);
[UIView commitAnimations];
textfield1.hidden=YES;
textfield2.hidden=YES;
textfield3.hidden=YES;
}
return YES;
}
//Set the objects on the view when device orientation will change.
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation ==UIInterfaceOrientationLandscapeRight) {
// set the views oreintation here for landscapemode.
}
if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ||
interfaceOrientation == UIInterfaceOrientationPortrait) {
//set the views oreintation here for Portraitmode.
}
}
//代表呼籲時方向會改變
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
來源
2012-03-22 12:24:41
Nit
你能不能換一種說法,並使其理解?你想要鍵盤出來? – Rengers 2010-03-30 12:28:18
我有五個基本問題 我有1個View.that視圖有10個UITextfields。這些不是放在xib文件上,而是我寫的代碼。 1>當我點擊UITextfield時,我的鍵盤應該隱藏所有UITextfields,它在我點擊的UITextfield下面 2>如果我點擊UITextfield並按回車,如果我自動旋轉那個視圖,在景觀上應該是一樣的,反之亦然。 3> 如果我點擊的UITextField與按回車鍵,如果我自轉這一觀點無論方式是在縱向視圖應該在landscapevie – user217572 2010-03-30 13:24:21
同樣意味着例如我是在4日的UITextField,當我上的UITextField點擊,鍵盤會隱藏下面的所有文本字段,只有UITextfield會在鍵盤上方。 現在,如果我的觀點是在肖像模式和我切換到橫向模式 – user217572 2010-03-30 13:50:36