我的按鈕沒有檢測到iPhone(Retina 4英寸)模擬器上的觸摸事件,但適用於iPhone(Retina 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. The buttons simply don't do anything when they're tapped. Has anyone else experienced this issue?

我正在使用模擬器為iPhone 5准備我的應用程序,我發現了一個奇怪的問題,在我的一個視圖中,我的幾個按鈕在iPhone(Retina 4英寸)模擬器中不起作用,但在iPhone(Retina 3.5英寸)模擬器中工作正常。這些按鈕在點擊時根本不做任何事情。還有其他人遇到過這個問題嗎?

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!

非常感謝您的所有智慧!

5 个解决方案

#1


32  

You need to edit your MainWindow.xib and enable "Full Screen at Launch". For a more detailed explanation, see Apple's docs:

您需要編輯MainWindow.xib並啟用“啟動時全屏”。有關更詳細的說明,請參閱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. 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.

要點:在Interface Builder中創建窗口時,建議您在屬性檢查器中啟用“啟動時全屏”選項。如果未啟用此選項且您的窗口小於目標設備的屏幕,則某些視圖將不會接收到觸摸事件。這是因為窗口(像所有視圖一樣)不會在其邊界矩形之外接收觸摸事件。由於默認情況下視圖不會剪切到窗口的邊界,因此視圖仍然顯示為可見但事件未到達它們。在啟動時啟用全屏選項可確保窗口的大小適合當前屏幕。

Complete document from Apple

來自Apple的完整文檔

#2


8  

For me, the solution was to set the size ("Simulated Metrics") to "Retina 4 Full Screen" for the MainWindow.xib. 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的大小(“Simulated Metrics”)設置為“Retina 4 Full Screen”。我不需要改變其他屏幕的大小(它們仍然設置為無)。更改MainWindow.xib后,底部區域再次可單擊...

#3


4  

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. Thanks, all!

由於彈簧和支柱的設置方式,問題是由於另一個控件重疊我的按鈕引起的。調整按鈕的z順序解決了問題。謝謝,全部!

#4


4  

There are two solution to this problem :

這個問題有兩種解決方案:

If you are using MainWindow follow these steps :

如果您使用的是MainWindow,請按照下列步驟操作:

a. Select MainWindow.xib.

一個。選擇MainWindow.xib。

b. Select Full Screen at Launch from Windows option available in Attributes Inspector.

灣在“屬性檢查器”中的“從Windows啟動”選項中選擇“全屏”。

If your application doesn't contain MainWindow then just add:

如果您的應用程序不包含MainWindow,則只需添加:

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

in ViewDidLoad.

在ViewDidLoad中。

#5


1  

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);

視圖.origin對於3.5英寸和4英寸的屏幕是不同的,因此,當為兩者編寫公共代碼時,我們需要注意給出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.

設定溫度。 diff視圖的差異背景顏色,以便您可以檢查是否有任何視圖重疊,以獲取4.0英寸的事件。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/09/19/abd1d5402c3984af313c8e76e1f0d119.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com