2016-07-14 52 views
0

我有一個關於iOS中的「完成」按鈕的問題,是否可以使用完成按鈕作爲用Swift編碼的應用程序的退出或關閉按鈕?Swift AVPlayerViewController完成按鈕關閉應用程序

我想要構建的應用程序只有一個視頻的獨立應用程序,當我單擊主屏幕上的應用程序按鈕時,必須打開並播放視頻,如果點擊左上角的「完成」角落必須關閉。

我的代碼是:

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. 
    } 


} 

編輯:對不起,我不知道,蘋果並不想關閉應用程序manuell。 好吧,那麼我想以另一種方式解決問題。

我有兩個ViewController在第一個(ViewConrtoller1)有一個按鈕,你可以去第二個視圖(ViewConrtoller2)。在第二部分中,有一個帶有所有控制器的視頻(播放,暫停,返回,轉發等),並在左上角還有「完成」按鈕。

我怎樣才能回來(ViewController2 - > ViewController1)第一個通過使用「完成」按鈕?那可能嗎?

謝謝:)

+0

根據Apple指導方針,您不要以編程方式退出或關閉任何應用程序。如果你真的需要沒有提交到App Store,然後嘗試退出(0)... –

+1

可能回答你的問題:http://stackoverflow.com/questions/5360846/suspend-the-application – Idan

回答

1

庫馬爾的評論是正確的 - 你不應該放棄你的應用程序編程。 It violates the Apple guidelines for an iOS app

+0

對不起,我不知道該蘋果不想關閉應用程序manuell。那好吧,我想以另一種方式解決問題。 我有兩個ViewController在第一個(ViewConrtoller1)有一個按鈕,你可以去第二個視圖(ViewConrtoller2)。在第二部分中,有一個帶有所有控制器的視頻(播放,暫停,返回,轉發等),並在左上角還有「完成」按鈕。 如何通過使用「完成」按鈕回到第一個?那可能嗎? –

相關問題