how do i exit an app after i touch any where on the screen ?

Hi

I have a question of how to exit an app after i tap anywhere on the screen.

I am using the AVKit in swift how can i exit the player app if I taped anywhere on screen ?

Replies

You have several ways:

- add a tapGesture to the top level view (whole screen). Implement an exit func.

But the exit func is always more or less a crash: exit(0) or fatalError()

- Make the top view a UIControl in IB (it is a subclass of UIView, so it is possible)

Then connect the view to the IBAcion for touchUp Inside:

     @IBAction func quit(_ sender: UIControl) {
          exit(0)
     }


Take care, this may not be accepted on Appstore.

You should al least first display an alert proposing to quit or not.