1

I'm relatively new to iOS development, but I'm having a go at working on some open source code for an old game that used to be pretty popular (Eden World Builder)

I've made quite a lot of progress in cleaning up the codebase, making small changes. But there's an issue I can't seem to fix. Every button in the game will not respond to taps around the edges of the screen. If a button is in the corner of the screen, you will have to tap towards the bottom of the button.

I've tried to move the buttons away from the edges, and they work, but that isn't practical for use. So there's something preventing the edges of the screen from registering button taps for some reason, and it doesn't seem to be anything to do with the button target areas themselves.

One thing I've noticed: This game is currently on the App Store, even though it hasn't been updated since 2015. In the App Store version (Which is built from the same code that I have) the issue doesn't occur. It must be something to do with building it in a newer version of Xcode, right?

Any assistance would be very helpful, this has been frustrating me for weeks now. Thanks

Ryan Kontos
  • 11
  • 1
  • 2
  • Below link useful for you. https://stackoverflow.com/questions/23046539/uibutton-fails-to-properly-register-touch-in-bottom-region-of-iphone-screen Thanks – Anbu Apr 17 '18 at 05:43
  • Make sure that root UIWindow bounds.size and frame.size do not have opposite height and width. – Andrew Bogaevskyi Apr 17 '18 at 09:27

2 Answers2

1

The answer to your first question is most likely either that your button is outside its parent view, or a gesture recognizer is interfering.

If a button extends beyond its parent views boundaries (or any of its higher parents' boundaries), it will still be visible as long as the parent doesn't have clipping enabled. The result is that you will still see the button, but it will only respond when touching the parts that are inside the parent view. You can find this visually by using Xcode View UI Hierarchy found in the Debug Navigator.

View UI Hierarchy

If it is gesture recognizers that interfere with your button, there are several solutions that might work. Several are described in the link you got from @Anbu in the comment.

The answer to your second question is that old apps are linked against old frameworks. Even if they run on the latest iOS version, they still pull in older versions of the framework, causing them to (mostly) continue work as before. This is done to keep compatibility with legacy code.

LGP
  • 4,135
  • 1
  • 22
  • 34
0

Try adding this to viewDidAppear

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if let window = view.window,
        let recognizers = window.gestureRecognizers {
        recognizers.forEach { r in
            r.delaysTouchesBegan = false
            r.cancelsTouchesInView = false
            r.isEnabled = false
        }
    }
}
Mina Makar
  • 51
  • 10