• <legend id='nvTwK'><style id='nvTwK'><dir id='nvTwK'><q id='nvTwK'></q></dir></style></legend>

      <tfoot id='nvTwK'></tfoot>

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

        • <bdo id='nvTwK'></bdo><ul id='nvTwK'></ul>
        <i id='nvTwK'><tr id='nvTwK'><dt id='nvTwK'><q id='nvTwK'><span id='nvTwK'><b id='nvTwK'><form id='nvTwK'><ins id='nvTwK'></ins><ul id='nvTwK'></ul><sub id='nvTwK'></sub></form><legend id='nvTwK'></legend><bdo id='nvTwK'><pre id='nvTwK'><center id='nvTwK'></center></pre></bdo></b><th id='nvTwK'></th></span></q></dt></tr></i><div id='nvTwK'><tfoot id='nvTwK'></tfoot><dl id='nvTwK'><fieldset id='nvTwK'></fieldset></dl></div>
      1. 为 UIImageView 实现 UITouchDown

        Implement UITouchDown for UIImageView(为 UIImageView 实现 UITouchDown)
              <i id='ZEum9'><tr id='ZEum9'><dt id='ZEum9'><q id='ZEum9'><span id='ZEum9'><b id='ZEum9'><form id='ZEum9'><ins id='ZEum9'></ins><ul id='ZEum9'></ul><sub id='ZEum9'></sub></form><legend id='ZEum9'></legend><bdo id='ZEum9'><pre id='ZEum9'><center id='ZEum9'></center></pre></bdo></b><th id='ZEum9'></th></span></q></dt></tr></i><div id='ZEum9'><tfoot id='ZEum9'></tfoot><dl id='ZEum9'><fieldset id='ZEum9'></fieldset></dl></div>
                <tbody id='ZEum9'></tbody>
            • <small id='ZEum9'></small><noframes id='ZEum9'>

              • <bdo id='ZEum9'></bdo><ul id='ZEum9'></ul>
                <tfoot id='ZEum9'></tfoot>

                1. <legend id='ZEum9'><style id='ZEum9'><dir id='ZEum9'><q id='ZEum9'></q></dir></style></legend>

                2. 本文介绍了为 UIImageView 实现 UITouchDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道如何为 UIImageView 实现 touchesBegan

                  I know how to implement touchesBegan for UIImageView

                  是否可以为 UIImageView 实现 UITouchDown ?(我知道我可以使用 touchesBegan 而不是 UITouchDown 但我想实现 UITouchDown)

                  is it possible to implement UITouchDown for UIImageView ?(i know that i can use touchesBegan instead of UITouchDown but i want to implement UITouchDown)

                  推荐答案

                  使用 UIButton.

                  UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
                  [aButton setImage:someUIImage forState:UIControlStateNormal];
                  [aButton addTarget:self action:@selector(aMethod) forControlEvents:UIControlEventTouchUpInside];
                  
                  [self.view addSubview:aButton];
                  

                  UIButton 的替代品(更长的方法)

                  UIControl 已经实现了用户交互并支持细粒度的用户交互.您可以结合 UIImageViewUIControl 的功能来实现这一点,因为它们都是 UIView 的子类.

                  A UIControl implements user interactions and support for fine-grained user interactions already. You can combine the functionality of a UIImageView and a UIControl to achieve this since both are subclasses of UIView.

                  要获得此行为,请将 UIImageView 的对象作为子视图添加到 UIControl 以便完全覆盖图像.然后使用 addTarget:action:forControlEvents:.这是一个例子:

                  To get this behavior, add an object of UIImageView as a subview to a UIControl such that the image is fully covered. Then add a event handler to this control using addTarget:action:forControlEvents:. Here's an example:

                  // assuming the image view object exists
                  UIImageView *anImageView = ..;
                  
                  // create a mask that the covers the image exactly
                  UIControl *mask = [[UIControl alloc] initWithFrame:anImageView.frame];
                  
                  // add the image as a subview of this mask
                  CGSize imageSize = anImageView.frame.size;
                  anImageView.frame = CGRectMake(0, 0, imageSize.width, imageSize.height);
                  [mask addSubview:anImageView];
                  
                  // add a target-action for the desired control events to this mask
                  [mask addTarget:self action:@selector(someMethod:) forControlEvents:UIControlEventTouchUpInside];
                  
                  // add the mask as a subview instead of the image
                  [self.view addSubview:mask];
                  

                  这篇关于为 UIImageView 实现 UITouchDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                  Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)
                  Create UIImage cutout(创建 UIImage 抠图)
                  Draggable UIImageView Partially Transparent amp; Irregular Shaped(可拖动的 UIImageView 部分透明 amp;不规则形状)
                  How to set the resolution of a saved image from the UIImagePickerController(如何从 UIImagePickerController 设置保存图像的分辨率)

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

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

                        <tbody id='qVXRE'></tbody>

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