Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIPopoverController在键盘弹出时设置动画_Iphone_Xcode_Ipad_Animation_Uipopovercontroller - Fatal编程技术网

Iphone UIPopoverController在键盘弹出时设置动画

Iphone UIPopoverController在键盘弹出时设置动画,iphone,xcode,ipad,animation,uipopovercontroller,Iphone,Xcode,Ipad,Animation,Uipopovercontroller,嘿 在我的iPad应用程序中,我有一个UIPopoverController和一个包含一些文本字段的UIViewController 当键盘打开时,Popover会根据需要设置动画。有人知道如何禁用此功能吗 谢谢我不认为你能做的就是把弹出框的高度变小……就是这样,当你的键盘弹出时,没有一个弹出框被它覆盖(因此它缩小了),但是我发现它有时很烦人,因为它会弄乱表视图(不能让它们一直滚动并且不得不调整它们的大小)如果它真的能为屏幕的更好部分设置动画,那就太好了。我想你的意思是,它实际上缩小了弹出窗口,

在我的iPad应用程序中,我有一个UIPopoverController和一个包含一些文本字段的UIViewController

当键盘打开时,Popover会根据需要设置动画。有人知道如何禁用此功能吗


谢谢

我不认为你能做的就是把弹出框的高度变小……就是这样,当你的键盘弹出时,没有一个弹出框被它覆盖(因此它缩小了),但是我发现它有时很烦人,因为它会弄乱表视图(不能让它们一直滚动并且不得不调整它们的大小)

如果它真的能为屏幕的更好部分设置动画,那就太好了。我想你的意思是,它实际上缩小了弹出窗口,这通常是不好的。(在我的例子中,我在旋转过程中看到)。除非移动视图,否则无法防止弹出窗口挤压。处理这一问题的最佳方法是用键盘临时将整个屏幕的整个主视图向上移动,移动幅度为弹出窗口的大小和如果不向上移动弹出窗口会缩小多少之间的差值。。。你不能仅仅根据键盘的大小将其向上移动,因为弹出窗口的高度也会受到影响。下面的代码是关于键盘旋转时的代码,与第一次使用时的代码类似。容易做,除了当你旋转屏幕,然后事情变得棘手

换句话说,有时候你的UIView根本不会移动,有时候它会向上移动170点

//-----------------找到键盘顶部(也用于“didRotate”)——非常方便, //我花了好几个小时才想出一个绝对的“永远工作”的跳板,给你-------

棘手的部分是找到弹出窗口的底部,因为弹出窗口本身或convertRect:toView:code中似乎有代码使原点变薄(如果您尝试在“convertRect:toView:code”之后“查看”原点),它希望在旋转过程中移动并处于不同的位置(或它的超级视图之一)因此,底部计算有时会有所不同(不可预测),因为不同元素旋转的异步过程可能是因为弹出窗口本身在弹出窗口中有许多超级视图。(若要查看弹出窗口的操作问题,并且必须有键盘影响弹出窗口,请向上移动整个视图,然后在“convertRect:toView:”代码后记录弹出窗口的“原点”和“大小”)。。。我所说的“原点”是在使用“convertRect:toView:”代码将框架转换为主视图(或至少向上几个视图)之后的框架原点

更新:(如果你从弹出窗口向下移动大约3个超视图,薄片就会消失…(下面的代码是“didRotate”ipad类型的代码。也就是说,在你可以到达投影到正确帧顶部的超视图之前,弹出窗口有几个超视图

UIPopoverController可能应该有一个属性,该属性具有旋转后预测的原点,在一种“will rotate”类型的代码中(由于键盘问题),而不仅仅是“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];
    }
}

你知道吗?我面临着同样的问题。不,我没有。仍然困扰着我:/嘿,在从头开始之后,我能够解决这个问题。结果我创建了自己的UIViewController类,它只添加了一些功能,比如完成块。显然,我在这个类中添加了一些代码来制作键盘动画。我感觉当我意识到这一点时有点傻,但我想我会回电话说我的弹出窗口不再动画。实际的弹出窗口将移动,但控件将保持在其中的固定位置。我的问题是文本字段是双重动画。我想我们有不同的问题,尽管它们听起来相似。
//--------------------------------------------------------------------------------
- (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];
            }
        }