0
我有一個UIView與其中的另一個UIView。在裏面的UIView有我要填寫一個文本框當我嘗試以填補它在鍵盤塊我的觀點:鍵盤阻止我的看法
的UIViewController中有以下
containerView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.view=containerView;
//The apropriate releases etc are further on...
當我觸摸它時,鍵盤按預期方式出現,但會阻止我試圖填充的文本框。如何強制視圖向上滑動?
前視圖
OptionsFront * fv = [[OptionsFront alloc] initWithFrame:[UIScreen mainScreen].bounds];
[containerView addSubview:frontView];
在正視圖是一個子視圖
CGRect bounds = CGRectMake(0.0f, 210.0f, 280.0f, 130.0f);
sv = [[UIView alloc] initWithFrame:bounds];
[self addSubview:sv]; //added to frontView
在SV是鈕附近的文本框:
rect = CGRectMake(70.0f, 20.0f, 100.0f, 27.0f);
cf = [self createTextField_Rounded:rect holder:@"+ve"];
[sv addSubview:cf];
所以CF恰好是近頁面的底部。我預計當我選擇它時,整個顯示屏會向上移動,但鍵盤只是向上移動並阻止它。
我該怎麼辦?
附錄:
- (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;
}
謝謝!很優雅的解決方案 – 2010-04-22 18:36:40