0

i have a question about the "Done"-Button in iOS Player, is it possible to use the Done-Button as a Exit or Close Button for Apps coded with Swift?

App that i want to build is a Standalone App with only one video, when i click the App Button on the Homescreen, it have to open and play the video, if i click on "Done" in the Top-Left Corner it have to be closed.

My Code is:

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {

    var playerViewController = AVPlayerViewController()
    var playerView = AVPlayer()

    override func viewDidLoad() {
        super.viewDidLoad()


    }

    override func viewDidAppear(animated: Bool) {

        let fileURL = NSBundle.mainBundle().pathForResource("Befeuchtungsstrecke", ofType: "mp4")
        playerView = AVPlayer(URL: NSURL(fileURLWithPath: fileURL!))

        playerViewController.player = playerView
        self.presentViewController(playerViewController, animated: true){

            self.playerViewController.player?.play()

        }



    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

EDIT: sorry i don't know that apple don't want to close a App manuell. Ok then, i want to solve the problem in another way.

I have two ViewController in the first one (ViewConrtoller1) there is a Button where you can go to the second view (ViewConrtoller2). In the Second there is a video with all Controller (Play, Pause, Back, Forward etc.) and also have the "Done" Button on Top-Left Corner.

How can i get back (ViewController2 --> ViewController1) to the first by using "Done" Button? Is that possible?

Thanks :)

Xeven Elewen
  • 65
  • 1
  • 1
  • 9
  • U dont exit or close any app programmatically as per the Apple guidelines . If u really need without submitting to the App Store then try with exit(0)... – Kumar KL Jul 14 '16 at 07:09
  • 1
    Might answer your question: http://stackoverflow.com/questions/5360846/suspend-the-application – Idan Jul 14 '16 at 07:11

1 Answers1

1

Kumar's comment is right - you shouldn't quit your app programatically. It violates the Apple guidelines for an iOS app.

Kumar KL
  • 15,315
  • 9
  • 38
  • 60
bitops
  • 4,022
  • 3
  • 26
  • 31
  • sorry i don't know that apple don't want to close a App manuell. Ok then, i want to solve the problem in another way. I have two ViewController in the first one (ViewConrtoller1) there is a Button where you can go to the second view (ViewConrtoller2). In the Second there is a video with all Controller (Play, Pause, Back, Forward etc.) and also have the "Done" Button on Top-Left Corner. How can i get back to the first by using "Done" Button? Is that possible? – Xeven Elewen Jul 14 '16 at 08:25