私のiPadアプリケーションでは、フォームシートスタイルを使用してコントローラーを提示しています
controller.modalPresentationStyle=UIModalPresentationFormSheet;
横向きモードでは、デバイスのキーボードが開いている間、ユーザーがテーブルのすべてのレコードを表示できるように、tableView のサイズを設定します。
キーボードの表示/非表示のイベントを取得します。設定しましたNSNotification
問題
しかし、ユーザーが外部/仮想キーボードを使用してテーブル セルの textField をタップすると、キーボードの表示/非表示のイベントが発生しません。したがって、textfield がファーストレスポンダになると、Tableview のサイズは小さくなりますが、ユーザーが外部キーボードに接続している間は必要ありません。
誰でもここでガイド/ヘルプをお願いできますか?どうすればよいですか? 外付けキーボードを使用するときに設定サイズを停止できるようにします。
キーボード イベントの登録
- (void)registerForKeyboardNotifications{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
}
AutoRotate とテキスト フィールドがファーストレスポンダになるときにフレームを設定する
-(void)setFramesOfTable
{
CGRect rct=tableView.frame;
if(appDel.isThisIPad && ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationLandscapeRight) && [selectedField isFirstResponder])
{
rct.size.height=400.0;
}
else
{
rct.size.height=576.0;
}
tableView.frame=rct;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
selectedField = textField;
[self setFramesOfTable];
}
-(NSUInteger)supportedInterfaceOrientations
{
[self setFramesOfTable];
return UIInterfaceOrientationMaskAll;
}
ありがとう。