<i id='btDLV'><tr id='btDLV'><dt id='btDLV'><q id='btDLV'><span id='btDLV'><b id='btDLV'><form id='btDLV'><ins id='btDLV'></ins><ul id='btDLV'></ul><sub id='btDLV'></sub></form><legend id='btDLV'></legend><bdo id='btDLV'><pre id='btDLV'><center id='btDLV'></center></pre></bdo></b><th id='btDLV'></th></span></q></dt></tr></i><div id='btDLV'><tfoot id='btDLV'></tfoot><dl id='btDLV'><fieldset id='btDLV'></fieldset></dl></div>

    <legend id='btDLV'><style id='btDLV'><dir id='btDLV'><q id='btDLV'></q></dir></style></legend>
    <tfoot id='btDLV'></tfoot>

  1. <small id='btDLV'></small><noframes id='btDLV'>

      • <bdo id='btDLV'></bdo><ul id='btDLV'></ul>

      如何通过点击动画 UIImageview 以显示全屏?

      时间:2023-06-01
      • <bdo id='WBttG'></bdo><ul id='WBttG'></ul>

        <small id='WBttG'></small><noframes id='WBttG'>

        <tfoot id='WBttG'></tfoot>

          <tbody id='WBttG'></tbody>
        • <i id='WBttG'><tr id='WBttG'><dt id='WBttG'><q id='WBttG'><span id='WBttG'><b id='WBttG'><form id='WBttG'><ins id='WBttG'></ins><ul id='WBttG'></ul><sub id='WBttG'></sub></form><legend id='WBttG'></legend><bdo id='WBttG'><pre id='WBttG'><center id='WBttG'></center></pre></bdo></b><th id='WBttG'></th></span></q></dt></tr></i><div id='WBttG'><tfoot id='WBttG'></tfoot><dl id='WBttG'><fieldset id='WBttG'></fieldset></dl></div>

                <legend id='WBttG'><style id='WBttG'><dir id='WBttG'><q id='WBttG'></q></dir></style></legend>

                本文介绍了如何通过点击动画 UIImageview 以显示全屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我在 UITableviewCell 中有一个 UIImageView.当它被点击时, UIImageView 应该动画以全屏显示.当图像在全屏时被点击时,它应该收缩回原来的位置.

                I have an UIImageView in a UITableviewCell. When it is tapped, the UIImageView should animated to be displayed fullscreen. When the image is tapped when it is fullscreen it should shrink back to the original position.

                如何做到这一点?

                推荐答案

                向视图控制器添加手势识别器.

                Add a gesture recognizer to the view controller.

                将手势识别器添加到您的头文件中

                Add the gesture Recognizer to your header file

                @interface viewController : UIViewController <UIGestureRecognizerDelegate>{
                    UITapGestureRecognizer *tap;
                    BOOL isFullScreen;
                    CGRect prevFrame;
                }
                

                在你的 viewDidLoad 中添加这个:

                In your viewDidLoad add this:

                isFullScreen = false;
                tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imgToFullScreen)];
                tap.delegate = self;
                

                添加以下委托方法:

                - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
                {
                    BOOL shouldReceiveTouch = YES;
                
                    if (gestureRecognizer == tap) {
                        shouldReceiveTouch = (touch.view == yourImageView);
                    }
                    return shouldReceiveTouch;
                }
                

                现在您只需要实现您的 imgToFullScreen 方法.确保使用 isFullScreen Bool(如果为 false,则为全屏,如果为 true,则返回旧尺寸)

                Now you just need to implement your imgToFullScreen method. Make sure you work with the isFullScreen Bool (fullscreen if it is false and back to old size if it's true)

                imgToFullScreen 方法取决于您希望如何使图像变为全屏.一种方法是:(这是未经测试的,但应该可以工作)

                The imgToFullScreen method depends on how you want to make the image become fullscreen. One way would be: (this is untested but should work)

                -(void)imgToFullScreen{
                    if (!isFullScreen) {
                        [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
                            //save previous frame
                            prevFrame = yourImageView.frame;
                            [yourImageView setFrame:[[UIScreen mainScreen] bounds]];
                        }completion:^(BOOL finished){
                            isFullScreen = true;
                        }];
                        return;
                    } else {
                        [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
                            [yourImageView setFrame:prevFrame];
                        }completion:^(BOOL finished){
                            isFullScreen = false;
                        }];
                        return;
                    }
                }
                

                这篇关于如何通过点击动画 UIImageview 以显示全屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:停止 segue 并显示警报 下一篇:没有了

                相关文章

                最新文章

                  <bdo id='IYRyt'></bdo><ul id='IYRyt'></ul>
              1. <small id='IYRyt'></small><noframes id='IYRyt'>

              2. <legend id='IYRyt'><style id='IYRyt'><dir id='IYRyt'><q id='IYRyt'></q></dir></style></legend>

                  <i id='IYRyt'><tr id='IYRyt'><dt id='IYRyt'><q id='IYRyt'><span id='IYRyt'><b id='IYRyt'><form id='IYRyt'><ins id='IYRyt'></ins><ul id='IYRyt'></ul><sub id='IYRyt'></sub></form><legend id='IYRyt'></legend><bdo id='IYRyt'><pre id='IYRyt'><center id='IYRyt'></center></pre></bdo></b><th id='IYRyt'></th></span></q></dt></tr></i><div id='IYRyt'><tfoot id='IYRyt'></tfoot><dl id='IYRyt'><fieldset id='IYRyt'></fieldset></dl></div>

                1. <tfoot id='IYRyt'></tfoot>