7中无法正常工作

7中无法正常工作

本文介绍了UIButton在iOS 7中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是UIButton在iOS6中运行得非常好,但在某些时候无法响应iOS7中的触摸事件。
澄清请见下图:

I have a problem with a UIButton that works perfectly well in iOS6, but fails to respond to touch events in iOS7 up to a certain point.To clarify please see below image:

失败的按钮是UIView中的全部放弃按钮。 (请注意,此按钮仅暂时禁用,这不是问题。我只是没有启用按钮的最新测试的屏幕截图)

The button that fails is the "Discard All" button that is in the UIView. (Please note, this button is only disabled temporarily and that is NOT the issue. I just don't have a screenshot of the newest test where the button is enabled")

此按钮忽略所有触摸,除非首先按下UITableViewCell中的Discard或Retry按钮。(这确实会导致重新加载视图控制器,从而触发再次调用ViewDidLoad等生命周期方法。)
按下表格视图单元格中的放弃或重试按钮后,全部放弃按钮开始正常运行。

This button ignores all touches, unless one first presses the "Discard" or "Retry" buttons in the UITableViewCell. (This does cause a reload of the view controller, which triggers the lifecycle methods like ViewDidLoad to be called again.)After either the "Discard" or "Retry" buttons in the table view cell have been pressed, the "Discard All" button starts functioning correctly.

视图和全部丢弃按钮构建在Controller的XIB文件上而不是代码中。这仅在iOS7上失败,并且一旦触摸到taleview单元按钮就开始工作。

The view and the "Discard All" button are build on the Controller's XIB file and not in code. This only fails on iOS7, and starts working as soon as the taleview cell buttons are touched.

任何人都有任何想法吗?

Anyone have any ideas?

谢谢!

推荐答案

我昨晚找到了解决方案。
好​​的,那么我将上面的表视图和UIV放在一起iew元素到目标框架上。

I found the solution last night.Okay, so what happens is that I put the above table view and UIView elements onto a target frame.

我不是百分百肯定,但似乎在iOS6中按钮响应事件而不管它们放在何处。
由于某些原因在iOS7中当按钮位于框架之外时它应该在,它会忽略触摸事件,即使它确实显示出来。

I'm not 100% sure, but it seems that in iOS6 the buttons respond to events irrespective of where they are placed.For some reason in iOS7 when the button sits outside of the frame it is supposed to be in, it ignores touch events, even though it does get displayed.

我通过将视图的框架放在正确的位置来解决问题,因此它覆盖了按钮。

I solved the problem by positioning the view's frame in the correct place so it overlays the button.

如果我能找到有关此文档的任何文档,我将在此处发布。

If I can find any documentation around this, I will post here.

谢谢!

这篇关于UIButton在iOS 7中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:49