UIButton not responding at bottom of screen on iPad

UIButton does not respond to any touch when it is located at the bottom of the screen on the iPad (next to the home button). He has sensory access and he accepts events, but no reaction will ever be given to the goal. I checked the hierarchy of views, and that is definitely on top. This does not apply to the menu bar.

This happens only on the iPad, and only if it is at the bottom, I have no problems with the iPhone, the code for both devices is the same?

Does anyone know what could happen?

+4
source share
2 answers

OK, so I realized what the problem is.

These were the sizes of UIWindow. I mixed width and height (I create a UIWindow programmatically to be clear). Since I correctly set the decimal values ​​of the sub-views, they displayed correctly, but could not receive touch events where there was no window under it. To be safe, I am using this now:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
0
source

I just had a similar problem with an iPad application that wasn’t responding, except for the upper left quarter of the screen, but with a universal application that loads the main window from MainWindow.xib.

Since the application is universal and does not have two options for .xib, the size of the main window in xib is the iPhone. When launched on the iPad, this is not visible, since by default the UIWindow clipsToBounds property ("Clip Subviews" in the Xcode inspector) is NO, which means that subviews can draw outside the borders of the window and, therefore, can be visually displayed in full screen mode (if you want to see this, just set clipToBounds to YES in UIWindow, helps to understand).

To make sure that the window receives full-screen restrictions when loading from its .xib, in the Xcode properties for Windows there is the option "Full screen at startup". Please note that this is not consistent with the UIWindow public API, so something is easy to overlook when you simply look at the documentation for the UIWind class.

However, this value is highlighted in the "Viewing iOS Programming Guide" section in the "Windows" section in the "Creating Windows in the Interface" section in the special "Important" field ...

+1
source

Source: https://habr.com/ru/post/1339727/


All Articles