• <bdo id='lVGFF'></bdo><ul id='lVGFF'></ul>
      <legend id='lVGFF'><style id='lVGFF'><dir id='lVGFF'><q id='lVGFF'></q></dir></style></legend>

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

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

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

        如何以编程方式将 UIView 或 UIImageView 与“touch u

        时间:2023-08-31

      2. <tfoot id='F22hl'></tfoot>

        <legend id='F22hl'><style id='F22hl'><dir id='F22hl'><q id='F22hl'></q></dir></style></legend>
          <tbody id='F22hl'></tbody>
      3. <i id='F22hl'><tr id='F22hl'><dt id='F22hl'><q id='F22hl'><span id='F22hl'><b id='F22hl'><form id='F22hl'><ins id='F22hl'></ins><ul id='F22hl'></ul><sub id='F22hl'></sub></form><legend id='F22hl'></legend><bdo id='F22hl'><pre id='F22hl'><center id='F22hl'></center></pre></bdo></b><th id='F22hl'></th></span></q></dt></tr></i><div id='F22hl'><tfoot id='F22hl'></tfoot><dl id='F22hl'><fieldset id='F22hl'></fieldset></dl></div>

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

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

                  本文介绍了如何以编程方式将 UIView 或 UIImageView 与“touch up inside"之类的事件联系起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  Interface Builder 只允许我为按钮连接此类事件.但就像在 HTML 中一样,我只想有一个空白的 UIImageView - 只要用户点击它 - 就会调用一个方法.我希望有一些很酷的编程方式,我不知道.

                  Interface Builder will only allow me to hook up such events for an button. But like in HTML, I just want to haven an blank UIImageView where - as soon as the user taps it - a method is invoked. I hope there is some cool programmatically way of doing that, which I don't know about.

                  更新:

                  在创建 UIImageView 的视图控制器中,我尝试这样做:

                  In my View Controller that creates the UIImageView I tried to do this:

                  SEL actionSelector = @selector(doSomethingWhenImageIsTouched:);
                  [self.myUIImageView addTarget:nil action:actionSelector forControlEvents:UIControlEventTouchUpInside];
                  

                  编译器给了我一个警告,UIImageView 可能无法响应 addTarget:... 我必须做什么才能使其与 UIImageView 一起使用.我在文档中看到 UIImageView 不是从 UIControl 继承的,但是 addTarget: 是 UIControl 的一部分.

                  The compiler gives me a warning, that UIImageView may not respond to addTarget:... what do I have to do so that it works with an UIImageView. I see in the docs that UIImageView does not inherit from UIControl, but addTarget: is part of UIControl.

                  更新:

                  我在创建 UIImageView 后最终创建了一个 UIButton.然后我将该按钮的框架设置为 UIImageView 的框架,并将 alpha 设置为 0.1f.由于某种原因,如果 alpha 为 0.0f,它将不起作用.然后,我做了那个很酷的 addTarget: 事情...

                  I ended up creating an UIButton after creating the UIImageView. Then I set the frame of that button to the frame of the UIImageView, and alpha to 0.1f. For some reason, it will not work if alpha is 0.0f. And then, I did that cool addTarget: thing...

                  推荐答案

                  在 SDK 版本 3.2(我不知道可能更早)中,您可以将手势识别器添加到 UIView.UIGestureRecogniser 是一个抽象类,它允许您定义手势(点击、捏合、滑动等)并将其添加到 UIView 中,当手势识别器识别到手势时,它会在您想要的目标上触发一个动作.

                  In SDK version 3.2 (could be earlier i donno), you can add gesture recognizers to a UIView. UIGestureRecogniser is an abstract class that allows you to define a gesture (tap, pinch, swipe, etc) and add it to a UIView and when the gesture recognizer, recognizes the gesture, it fires up an action on a target of your desire.

                  在文档中阅读所有相关信息...:D

                  read all about it in the docs... :D

                  这篇关于如何以编程方式将 UIView 或 UIImageView 与“touch up inside"之类的事件联系起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android:ViewGroup,如何拦截MotionEvent然后派发到目标 下一篇:Android 中的 Lucene

                  相关文章

                  最新文章

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

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

                    <legend id='qWWQ7'><style id='qWWQ7'><dir id='qWWQ7'><q id='qWWQ7'></q></dir></style></legend>
                      • <bdo id='qWWQ7'></bdo><ul id='qWWQ7'></ul>