简体   繁体   中英

On iPhone 11, using a custom view, why is my Tap Recognizer or UIButton not responding on top part of View but works on lower part of View

I have a few custom action sheets. They are fully custom controls, not based on UIActionSheet. I add them as subview to the view controller and animate them in and out. They work fine on the older devices, but on iPhone 11 I have a problem. On a the ones that are most like the UIActionSheet, the top Action item is not clickable. The other items are clickable. In the debugger, I see that the code thinks I clicked outside my custom action sheet.

I also noticed that one of my other similar custom controls that slides up from the bottom and presents a collection view does not appear flush at the bottom of the screen as it does on older devices. It's a little higher up. But it works fine.

The problem was that in the XIB files that I made for each my custom controls, I was using SafeArea and the custom content view of the control was flush with the safe area. The view controller that I was presenting the control did not use the bottom safe area - that was an intentional part of the design so that the contents would go all the way to the bottom - no tab bar is shown on that screen.

But on the iPhone 11, there is a lower safe area. So when presenting the view, evidently the use of safe area in the XIB file meant that the view was showing higher up, not flush to the bottom of the screen in spite of the coordinates I gave it. But evidently some other part of the OS was "seeing" the content view as if it had been places where I said it should be lower down, flush with the bottom of the screen, and so touch sensitivity was cut off at the y coordinate of where I had asked the top of the view to be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM