2017-07-07 11 views
-1

こんにちは皆、私は助けが必要です)...私はボタンを3回押すとカウンターで "snapShotButton"ボタンを作りたいと思います。このアプリを使用するために "。私が「OK」を押すと、彼はMKStoreKitで支払います...私はMKStoreKitを持っていて、私のアプリはビデオエディタです...助けてくれてありがとう!!ボタン "保存"のカウンター

func addButtons() { 
 

 
let snapShotButton = UIButton(type: .system) 
 
     snapShotButton.setImage(#imageLiteral(resourceName: "snapShot").withRenderingMode(.alwaysOriginal), for: .normal) 
 
     snapShotButton.translatesAutoresizingMaskIntoConstraints = false 
 
     bottomTabBar.addSubview(snapShotButton) 
 
     snapShotButton.centerYAnchor.constraint(equalTo: bottomTabBar.centerYAnchor).isActive = true 
 
     snapShotButton.centerXAnchor.constraint(equalTo: bottomTabBar.centerXAnchor).isActive = true 
 
     snapShotButton.heightAnchor.constraint(equalToConstant: 32).isActive = true 
 
     snapShotButton.widthAnchor.constraint(equalToConstant: 32).isActive = true 
 
     snapShotButton.addTarget(self, action: #selector(snapShotButtonTapped), for: .touchUpInside) 
 
     snapShotButton.addTarget(self, action: #selector(counterAction), for: .touchUpInside) 
 
    } 
 

 
func counterAction(sender:UIButton){ 
 
     
 
     counter -= 1 
 
     print(counter) 
 
     
 
     if counter == 0 { 
 
     MKStoreKit.shared().initiatePaymentRequestForProduct(withIdentifier: "com.steinlogic.iapdemo.quarterly") 
 
     } 
 
    } 
 
    
 
    
 
    func snapShotButtonTapped() { 
 
     pauseVideo() 
 
     PHPhotoLibrary.shared().performChanges({ 
 
      PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.videoURL) 
 
     }) { saved, error in 
 
      if saved { 
 
       DispatchQueue.main.async { _ in 
 
        self.dismiss(animated: true, completion: nil) 
 
       } 
 
      } 
 
      else { 
 
       self.alertErrors() 
 
      } 
 
     } 
 
     //alertNotAvailable() 
 
    }

+0

このコードでは何が起こっていませんか? –

+0

何が問題なのですか? –

+0

コードは正しいですか?エラーはありますか? –

答えて

0

あなたはUserDefaultsにカウンタの値を保存し、すべてのアプリケーションの開始後にそれを盗ん必要があります。支払いが行われた後、カウンタの減分をすべてスキップできます。

+0

あなたに助けてくれてありがとう – YHWH