简体   繁体   English

我的按钮在iPhone(4英寸视网膜)模拟器上未检测到触摸事件,但在iPhone(3.5英寸视网膜)模拟器中有效

[英]My button doesn't detect touch events on iPhone (Retina 4-inch) simulator, but works in iPhone (Retina 3.5-inch) simulator

I'm getting my app ready for the iPhone 5 using the simulator and I've found a weird issue where a couple of my buttons, in one of my views, don't work in the iPhone (Retina 4-inch) simulator, but work fine in the iPhone (Retina 3.5-inch) simulator. 我正在使用模拟器为iPhone 5准备好应用程序,但发现了一个奇怪的问题,根据我的观点,我的几个按钮在iPhone(4英寸视网膜)模拟器中不起作用,但可以在iPhone(Retina 3.5英寸)模拟器中正常工作。 The buttons simply don't do anything when they're tapped. 轻按按钮时,它们根本不执行任何操作。 Has anyone else experienced this issue? 还有其他人遇到过这个问题吗?

I having a difficult time figuring out where to start with this one. 我很难弄清楚从哪里开始。 Any suggestions on where to start? 关于从哪里开始的任何建议?

Thanks so much in advance for all your wisdom! 非常感谢您的所有智慧!

You need to edit your MainWindow.xib and enable "Full Screen at Launch". 您需要编辑MainWindow.xib并启用“启动时全屏”。 For a more detailed explanation, see Apple's docs: 有关更详细的说明,请参阅Apple的文档:

Important: When creating your window in Interface Builder, it is recommended that you enable the Full Screen at Launch option in the attributes inspector. 重要:在Interface Builder中创建窗口时,建议您在属性检查器中启用“启动时全屏”选项。 If this option is not enabled and your window is smaller than the screen of the target device, touch events will not be received by some of your views. 如果未启用此选项,并且您的窗口小于目标设备的屏幕,则某些视图将不会接收触摸事件。 This is because windows (like all views) do not receive touch events outside of their bounds rectangle. 这是因为窗口(如所有视图)不会在其边界矩形之外接收触摸事件。 Because views are not clipped to the window's bounds by default, the views still appear visible but events do not reach them. 因为默认情况下视图未裁剪到窗口的边界,所以视图仍然显示为可见,但事件未到达它们。 Enabling the Full Screen at Launch option ensures that the window is sized appropriately for the current screen. 启用“启动时全屏”选项可确保窗口的大小适合当前屏幕。

Complete document from Apple Apple的完整文件

For me, the solution was to set the size ("Simulated Metrics") to "Retina 4 Full Screen" for the MainWindow.xib. 对我来说,解决方案是将MainWindow.xib的大小(“模拟度量”)设置为“ Retina 4 Full Screen”。 I did not need to alter the size of the other screens (they are still set to None). 我不需要更改其他屏幕的大小(它们仍设置为“无”)。 After changing the MainWindow.xib the bottom area becomes clickable again... 更改MainWindow.xib之后,底部区域再次变为可单击...

The problem was caused by another control overlapping my buttons due to the way the springs and struts were setup. 该问题是由于弹簧和支撑杆的设置方式导致另一个控件与我的按钮重叠而引起的。 Adjusting the z-order of the buttons fixed the issue. 调整按钮的z顺序可解决此问题。 Thanks, all! 谢谢大家!

There are two solution to this problem : 这个问题有两种解决方案:

If you are using MainWindow follow these steps : 如果您使用的是MainWindow,请按照以下步骤操作:

a. 一种。 Select MainWindow.xib . 选择MainWindow.xib

b. b。 Select Full Screen at Launch from Windows option available in Attributes Inspector. 在“属性检查器”中选择Full Screen at Launch从Windows Full Screen at Launch选项。

If your application doesn't contain MainWindow then just add: 如果您的应用程序不包含MainWindow,则只需添加:

self.view.frame = [UIScreen mainScreen].bounds

in ViewDidLoad. 在ViewDidLoad中。

I solved my prob. 我解决了我的问题。

view .origin for 3.5 inch and 4 inch screen are different so, when writing common code for both we need to take care at giving CGRectmake(x,y,w,h) ; 3.5英寸和4英寸屏幕的view .origin是不同的,因此,当为两者编写通用代码时,我们都需要注意给出CGRectmake(x,y,w,h)

Set temp. 设定温度 diff background color of diff view so you can check if any view is overlapping or not, to fetch event in 4.0 inch. 差异视图的差异背景颜色,因此您可以检查任何视图是否重叠,以获取4.0英寸的事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此代码仅适用于iPhone Retina 4英寸模拟器 - This code only works on iPhone Retina 4-inch simulator 为什么我的Xcode4.5没有iPhone(Retina 4英寸)和iPhone(Retina 3.5英寸) - Why my Xcode4.5 doesn't has iPhone(Retina 4-inch) and iPhone(Retina 3.5inch) 提取联系人在iPhone Retina 4英寸64位模拟器中不起作用,但在3.5英寸中可以正常工作 - Fetching contact is not working in iphone retina 4inch 64bit simulator but works fine in 3.5 inch UIScrollView适用于4英寸,不响应3.5英寸的任何触控 - UIScrollView works on 4-inch, doesn't respond to any touch on 3.5-inch 在4英寸iPhone模拟器中显示错误的高度 - Displaying wrong height in 4-inch iPhone simulator iPhone 未在 iPhone 5 模拟器上显示指定的 4 英寸启动图像 - iPhone doesn't show specified 4-Inch launch image on iPhone 5 Simulator 解析错误iPhone Retina(4英寸64位) - Parse Error iPhone Retina (4-inch 64bit) 无法在iPhone 6.0模拟器Retina 4英寸上全屏启动我的应用程序 - Unable to start my application in full screen on iPhone 6.0 Simulator Retina 4 Inch 从iPhone 4英寸屏幕xib的iPhone 3.5“模拟器中更改了视框 - View frame changed in the iPhone 3.5" simulator from iPhone 4-inch screen xib 在iPhone(3.5英寸视网膜)上正确显示图像的问题 - Issue with displaying the image correctly in iPhone(3.5 retina inch)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM