ねえ、
私の iPad アプリケーションには、いくつかのテキストフィールドを含む UIViewController を持つ UIPopoverController があります。
キーボードが表示されると、ポップオーバーがそれに合わせてアニメーション化されます。これを無効にする方法を知っている人はいますか?
ありがとう
ねえ、
私の iPad アプリケーションには、いくつかのテキストフィールドを含む UIViewController を持つ UIPopoverController があります。
キーボードが表示されると、ポップオーバーがそれに合わせてアニメーション化されます。これを無効にする方法を知っている人はいますか?
ありがとう
ポップオーバーの高さを小さくする以外にできないと思います...そのようになっているので、キーボードがポップアップすると、ポップオーバーが覆われることはありません(したがって、ポップオーバーが元に戻ります)が、時々迷惑になることがありますテーブルビューが混乱しているため(完全にスクロールできず、サイズを変更する必要があります)
実際に画面のより良い部分にアニメーション化されれば素晴らしいと思います.popUpを実際に縮小することを意味すると思いますが、これはほとんど良くありません.(私の場合、回転中に見られます). ビューを移動しない限り、ポップアップを押しつぶすことはできません。これを処理する最善の方法は、画面全体のメイン UIView 全体を、ポップアップのサイズと、ポップアップを上に移動しなかった場合にどれだけ縮小するかの差だけキーボードで一時的に移動することです。 . キーボードのサイズだけ上に移動することはできません。以下のコードは、キーボードが回転したときのもので、最初に導入されたときの同様のコードです。簡単にできますが、画面を回転させるときを除いて、物事はトリッキーになります...
言い換えれば、UIView がまったく動かない場合もあれば、170 ポイント上に移動する場合もあります。
//-----キーボードトップの検索 (「didRotate」でも使用)----非常に便利、//絶対に常に機能することを理解するのに何時間もかかりましたtopOfKeyboard では、どうぞ。-------
//--------------------------------------------------------------------------------
- (void)keyboardWillShow:(NSNotification*)notification
{
NSLog(@" keyboardWillShow");
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
NSDictionary* info = [notification userInfo];
keyboardRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardRect = [(UIView*)keyWindow convertRect:keyboardRect toView:mainViewController.view];
keyboardIsVisible = TRUE;
topOfKeyboard = keyboardRect.origin.y;
トリッキーな部分は、ポップアップ自体または convertRect:toView: コードに原点を不安定にするコードがあるように見えるため、PopUp の下部を見つけることです (「convertRect:toView:」コードの後に原点を「表示」しようとすると、 )、回転中に移動して別の場所(またはそのスーパービューの1つ)になりたいので、異なる要素の回転の非同期プロセスのために、おそらくポップアップ自体が原因で、ボトム計算が異なる場合があります(予測できません)ポップアップには多くのスーパービューがあります。(ポップアップで問題が発生しているのを確認するには、ポップアップに影響を与えるキーボードが必要です。ビュー全体を上に移動し、「convertRect:toView:」コードの後に popUp の「原点」と「サイズ」をログに記録します)...「原点」 " 私'
更新:(ポップアップから約 3 スーパービューを下に移動すると、不安定さがなくなります... (以下のこのコードは、「didRotate」iPad タイプのコードでした。つまり、ポップアップには、取得する前にいくつかのスーパービューがあるということです。適切なフレームの上に投影されたものに
UIPopoverController にはおそらく、「popoverContentSize」だけでなく、「回転する」種類のコードのタイプで、回転後に予測される原点を持つプロパティが必要です (キーボードの問題のため)。別の変数として、キーボードがなかったはずの popoverContentSize を含めます。
//--------------------------------------------------------------------------------
- (void) checkRotation
{
NSLog(@" ");
NSLog(@"checkRotation");
if (wasOffset)
{
wasOffset = false;
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:0.2f];
CGRect frame = carousel.frame;
frame.origin.y += offset;
carousel.frame = frame;
[UIImageView commitAnimations];
[popPickerController presentPopoverFromRect:zoneButton.frame inView:[zoneButton superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
if (popPickerController.popoverVisible)
{
if (keyboardIsVisible)
{
wasOffset = false;
[popPickerController presentPopoverFromRect:zoneButton.frame inView:[zoneButton superview]
permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
upView3 = [[[popPickerController.contentViewController.view superview] superview] superview]; //hey it works... :o)
//NSLog(@" ");
//NSLog(@"upView3.frame.origin.x = %f",upView3.frame.origin.x);
//NSLog(@"upView3.frame.origin.y = %f",upView3.frame.origin.y);
//NSLog(@"upView3.frame.size.height = %f",upView3.frame.size.height);
//NSLog(@"upView3.frame.size.width = %f",upView3.frame.size.width);
//NSLog(@" ");
popUpRect.origin.x = upView3.frame.origin.x;
popUpRect.origin.y = upView3.frame.origin.y;
popUpRect.size.height = popUpSize.height;
popUpRect.size.width = popUpSize.width; //you must save the size because the keyboard destroys it before you can use it. very tricky....
//NSLog(@" ");
//NSLog(@"popUpRect.origin.x = %f",popUpRect.origin.x);
//NSLog(@"popUpRect.origin.y = %f",popUpRect.origin.y);
//NSLog(@"popUpRect.size.height = %f",popUpRect.size.height);
//NSLog(@"popUpRect.size.width = %f",popUpRect.size.width);
//NSLog(@" ");
//NSLog(@" ");
//NSLog(@"keyboardIsVisible = %d", keyboardIsVisible);
//NSLog(@" ");
//NSLog(@"keyboardRect.origin.x = %f",keyboardRect.origin.x);
//NSLog(@"keyboardRect.origin.y = %f",keyboardRect.origin.y);
//NSLog(@"keyboardRect.size.height = %f",keyboardRect.size.height);
//NSLog(@"keyboardRect.size.width = %f",keyboardRect.size.width);
//NSLog(@"topOfKeyboard = %f",topOfKeyboard);
CGFloat bottomOfPicker = popUpRect.origin.y + popUpRect.size.height - amountShadowCanEncroach;
//NSLog(@" ");
//NSLog(@"bottomOfPicker = %f",bottomOfPicker);
//NSLog(@"topOfKeyboard = %f",topOfKeyboard);
//NSLog(@" ");
if (bottomOfPicker > topOfKeyboard)
{
wasOffset = true;
offset = bottomOfPicker - topOfKeyboard;
NSLog(@"offset = %f",offset);
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:0.2f];
CGRect frame = carousel.frame;
frame.origin.y -= offset;
carousel.frame = frame;
[UIImageView commitAnimations];
}
}
[popPickerController presentPopoverFromRect:zoneButton.frame inView:[zoneButton superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
and moving the main UIView back
//-----------------------------------------------------------------------------
- (void) searchDidEndEditing
{
NSLog(@"searchDidEndEditing");
keyboardIsVisible = false;
if (wasOffset)
{
wasOffset = false;
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:0.2f];
CGRect frame = mainView.frame;
frame.origin.y += offset;
mainView.frame = frame;
[UIImageView commitAnimations];
if (zoneButton.selected)
[popPickerController presentPopoverFromRect:zoneButton.frame inView:[zoneButton superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}