こんにちは、キーボードが に隠れているという問題があり UITextField
ましたUIScrollView
。
そのために、Apple ドキュメントのコードを使用しました。
ビューでDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
と
- (void)keyboardWasShown:(NSNotification*)aNotification
{
int rowNumber=(selectetTxtfld.tag-1)/7;
if (rowNumber>2) {
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGRect bkgndRect = selectetTxtfld.superview.frame;
bkgndRect.size.height += kbSize.height;
[selectetTxtfld.superview setFrame:bkgndRect];
[scrlView setContentOffset:CGPointMake(0.0, selectetTxtfld.frame.origin.y-200) animated:YES];
}
}
と
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
scrlView.contentInset = contentInsets;
scrlView.scrollIndicatorInsets = contentInsets;
scrlView.contentOffset=CGPointZero;
}
今では正常に動作しています。しかし、コード行でそれを聞いた
[scrlView setContentOffset:CGPointMake(0.0, selectetTxtfld.frame.origin.y-200) animated:YES];
キーボードの高さには 200 を使用しています。このように使用すると、アップルはアプリを拒否します。そうですか、そうではありませんか。
このコードも試しました。しかし、テキストフィールドとscrlviewのコンテンツを表示していません
[scrlView setContentOffset:CGPointMake(0.0, selectetTxtfld.frame.origin.y-kbSize.height) animated:YES];
私のアプリでは、向きを使用しています
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
そこで、キーボードの高さの使い方を教えてください。