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

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

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

        UIButton 在 iOS 5.x 中不起作用,在 iOS 6.x 中一切正常

        时间:2023-07-07
      2. <small id='nJPoY'></small><noframes id='nJPoY'>

          <bdo id='nJPoY'></bdo><ul id='nJPoY'></ul>

              <tbody id='nJPoY'></tbody>

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

              • <legend id='nJPoY'><style id='nJPoY'><dir id='nJPoY'><q id='nJPoY'></q></dir></style></legend>
                  本文介绍了UIButton 在 iOS 5.x 中不起作用,在 iOS 6.x 中一切正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  通过点击主 UIView 上的简单 UIButton,附加视图(子视图)出现在屏幕中心(以编程方式创建的子视图).在那个子视图上,我有 UIButton 启动 MPMoviePlayer(此代码在创建子视图的方法内部):

                  By tapping simple UIButton on main UIView, additional View (subview) appears in the center of screen (subview created programmatically). On that subview I have UIButton that launches MPMoviePlayer (this code is inside method that creates subview):

                   // Create play button
                  
                  UIButton *playButton = [UIButton buttonWithType:UIButtonTypeCustom];
                  [playButton addTarget:self
                                 action:@selector(wtf)
                       forControlEvents:UIControlEventTouchUpInside];
                  
                  [playButton setTitle:@"" forState:UIControlEventTouchUpInside];
                  [playButton setImage:[UIImage imageNamed:[self.playButtons objectAtIndex:[sender tag] - 1]] forState:UIControlStateNormal];
                  playButton.frame = playButtonRect;
                  playButton.userInteractionEnabled = YES;
                  

                  这个按钮在同一个方法中作为子视图添加到这个视图中:

                  This button added as subview to this view inside the same method:

                  [self.infoView addSubview:playButton];
                  

                  在 iOS Simulator 6.0 和带有 iOS 6.0 的真实设备中,一切正常,在 Simulator iOS 5.0 和带有 5.0 的设备中,我有一个非常奇怪的行为:只有当我通过这个按钮的区域进行拖动时,按钮才开始工作,当我只需点击按钮 - 它调用方法,当用户点击屏幕上的任何位置时调用,就像我的按钮没有出现在屏幕上(但在视觉上它确实出现了).我的目标是为 5.x 制作这个应用程序,所以我尝试在这个奇怪的问题上找到答案.

                  In iOS Simulator 6.0 and real device with iOS 6.0 everything works fine, in Simulator iOS 5.0 and device with 5.0 I have a very strange behavior: button start to work only when I made drag by the area of this button, when I just clicked on button - it called method what called when user taps anywhere in the screen, like my button doesn't appear on screen (but visually it does). My goal is to make this app for 5.x, so I try to find answer on this strange issue.

                  欢迎任何建议!

                  推荐答案

                  您是否正在向 infoView 或其任何子视图添加 UITapGestureRecognizer?

                  Are you adding a UITapGestureRecognizer to infoView or any of it subviews?

                  如果是这种情况,您的手势识别器正在禁止 UIButton 操作.您可以在 这篇文章

                  If that is the case, your gesture recognizer is inhibiting the UIButton action. You could use the solution provided by Kevin Ballard or cdasher on this post

                  您只需将具有 UITapGestureRecognizer 的视图设置为该手势识别器的委托 (UIGestureRecognizerDelegate).然后可以添加如下代码:

                  You just need to set the view that has the UITapGestureRecognizer as the delegate of that Gesture Recognizer (UIGestureRecognizerDelegate). Then you can add the following code:

                  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
                  {
                      return ! ([touch.view isKindOfClass:[UIControl class]]);
                  }
                  

                  您的点按手势识别器应如下所示:

                  And your Tap Gesture Recognizer should look like this:

                  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureAction)];
                  tap.delegate = self;
                  [self.view addGestureRecognizer:tap];
                  

                  希望这会有所帮助!

                  这篇关于UIButton 在 iOS 5.x 中不起作用,在 iOS 6.x 中一切正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 下一篇:故事板在按钮内的图像下方定位文本

                  相关文章

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

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

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

                      <tfoot id='ngH8a'></tfoot>
                        <bdo id='ngH8a'></bdo><ul id='ngH8a'></ul>