【发布时间】:2017-07-07 06:58:43
【问题描述】:
大家好,我需要帮助伙计们)...当我按下按钮 3 次时,我想制作一个带有计数器的按钮“snapShotButton”,我想在写“你需要为使用此应用程序付费”的地方发出警报。当我按“确定”时,他将使用 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()
}
【问题讨论】:
-
这段代码有什么问题?
-
到底是什么问题?
-
您的代码对我来说看起来正确吗?有什么错误吗?
标签: swift button save counter payment