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

      • <bdo id='1upfj'></bdo><ul id='1upfj'></ul>

      你如何知道在 touchesBegan 中被触摸的对象是什么?

      How do you tell what object is being touched in touchesBegan?(你如何知道在 touchesBegan 中被触摸的对象是什么?)
        <tbody id='Koz6c'></tbody>

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

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

              • <bdo id='Koz6c'></bdo><ul id='Koz6c'></ul>
                <legend id='Koz6c'><style id='Koz6c'><dir id='Koz6c'><q id='Koz6c'></q></dir></style></legend>
                本文介绍了你如何知道在 touchesBegan 中被触摸的对象是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道这是一个非常常见的问题,但是每个网站上的所有答案都不起作用!如果你还是不明白我的意思,那么也许这行代码可以帮助你理解.

                I know that this is a very commonly asked question, but all of the answers on every website don't work! If you still don't know what I mean, then maybe this line of code will help you understand.

                
                - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
                    UITouch *touch = [[event allTouches] anyObject];
                    CGPoint location = [touch locationInView:self.view];
                    if (touch.view == nextbutton)
                        [self performSelector:@selector(next)];
                    if (touch.view == prevbutton)
                        [self performSelector:@selector(previous)];
                    if (touch.view == moreoptionsbutton)
                        [self performSelector:@selector(moresettings)];
                }
                

                当你触摸 nextbutton、prevbutton 和 more optionsbutton 时,它不会做任何事情,顺便说一下,它们是 UIImageViews.我也尝试过使用 isEqual: 而不是 ==,但这也没有成功.有什么建议吗?

                It doesn't do anything when you touch nextbutton, prevbutton, and more optionsbutton, which are UIImageViews by the way. I have also tried using isEqual: instead of ==, but that hasn't worked out either. Any suggestions?

                推荐答案

                你必须为你所有的 UIImageViews 设置 userinteractionEnabled = YES 否则他们将不会收到触摸事件.同时换行:

                You have to set userinteractionEnabled = YES for all your UIImageViews otherwise they will not receive touch events. Also change the line:

                 UITouch *touch = [[event allTouches] anyObject];
                

                 UITouch *touch = [touches anyObject];
                

                这篇关于你如何知道在 touchesBegan 中被触摸的对象是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)
                    <i id='5nbxR'><tr id='5nbxR'><dt id='5nbxR'><q id='5nbxR'><span id='5nbxR'><b id='5nbxR'><form id='5nbxR'><ins id='5nbxR'></ins><ul id='5nbxR'></ul><sub id='5nbxR'></sub></form><legend id='5nbxR'></legend><bdo id='5nbxR'><pre id='5nbxR'><center id='5nbxR'></center></pre></bdo></b><th id='5nbxR'></th></span></q></dt></tr></i><div id='5nbxR'><tfoot id='5nbxR'></tfoot><dl id='5nbxR'><fieldset id='5nbxR'></fieldset></dl></div>
                      <tbody id='5nbxR'></tbody>

                        <bdo id='5nbxR'></bdo><ul id='5nbxR'></ul>
                      • <tfoot id='5nbxR'></tfoot>

                          <legend id='5nbxR'><style id='5nbxR'><dir id='5nbxR'><q id='5nbxR'></q></dir></style></legend>
                        1. <small id='5nbxR'></small><noframes id='5nbxR'>