- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试将托管内容添加为单一 View 应用的 IAP。但是,在编码时,我在 Xcode 7 中不断收到以下错误
“ View Controller 不符合 SKPaymentTransactionObserver、SKProductsRequestDelegate 的协议(protocol)”
这是代码。
import UIKit
import StoreKit
class ViewController: UIViewController, SKPaymentTransactionObserver, SKProductsRequestDelegate {
@IBOutlet weak var lblQuotes: UILabel!
@IBOutlet weak var btnAnotherQuote: UIButton!
@IBOutlet weak var btnRemoveAds: UIButton!
@IBOutlet weak var btnGetTheGuide: UIButton!
@IBOutlet weak var btnRestore: UIButton!
var quoteArray = ["Coming together is a beginning; keeping together is progress; working together is success...Henry Ford","Success is not final, failure is not fatal...Winston Churchill", "It is no use saying, 'We are doing our best...You have got to succeed in doing what is necessary...Winston Churchill", "The price of success is hard work, dedication to the job at hand....Vince Lombardi","Failure is not an option. Everyone has to succeed...Arnold Schwarzenegger","Happiness lies in the joy of achievement and the thrill of creative effort...Franklin D. Roosevelt","Success is a lousy teacher. It seduces smart people into thinking they can't lose...Bill Gates","Frustration, although quite painful at times, is a very positive and essential part of success.","There is little success where there is little laughter...Andrew Carnegie","Success is not forever and failure isn't fatal...Don Shula", "Success is getting what you want. Happiness is wanting what you get.","The secret of my success is a two word answer: Know people...Harvey S. Firestone","Formal education will make you a living; self-education will make you a fortune...Jim Rohn","When love and skill work together, expect a masterpiece...John Ruskin","If you have no critics you'll likely have no success...Malcolm X","The ladder of success is best climbed by stepping on the rungs of opportunity.","There is only one success - to be able to spend your life in your own way...Christopher Morley","There is no success without hardship...Sophocles","Success is dependent on effort...Sophocles","As kids we're not taught how to deal with success; we're taught how to deal with failure...Charlie Sheen","Success isn't a result of spontaneous combustion. You must set yourself on fire...Arnold H. Glasow","Success is a state of mind. If you want success, start thinking of yourself as a success...Joyce Brothers","Strive not to be a success, but rather to be of value...Albert Einstein","Eighty percent of success is showing up...Woody Allen","Success is achieved and maintained by those who try and keep trying...W. Clement Stone","Success is not measured by what you accomplish, but by the opposition you have encountered...Orision Swett Marden","Success comes from knowing that you did your best to become the best that you are capable of becoming...John Wooden","Formula for success: rise early, work hard, strike oil...J. Paul Getty","It would be wonderful to enjoy success without seeing envy in the eyes of those around you.","If everyone is moving forward together, then success takes care of itself...Henry Ford","A person needs their difficulties to enjoy success.","Success depends upon previous preparation, and without such preparation there is sure to be failure...Confucius","Success is simple. Do what's right, the right way, at the right time...Arnold H. Glasow","The foundation stones for a balanced success are honesty, character, integrity, faith, love and loyalty...Zig Ziglar","No man succeeds without a good woman behind him. Wife or mother, if it is both, he is twice blessed indeed...Godfret Winn","All you need in this life is ignorance and confidence, and then success is sure...Mark Twain","Success is finding satisfaction in giving a little more than you take...Christpher Reeve","Try not to become a person of success, but rather try to become a person of value...Albert Einstein","Success consists of going from failure to failure without loss of enthusiasm...Winston Church","Success is how high you bounce when you hit bottom...George S.Patton","Desire is the key to motivation, but it's determination and,commitment to an unrelenting pursuit of your goal.","Don't aim for success if you want it; just do what you love and believe in, and it will come naturally...David Frost","The starting point of all achievement is desire...Napolean Hill","Success is nothing more than Schwarzenegger few simple disciplines, practiced every day...","If you love what you are doing, you will be successful."]
var numberQuote = 40
var buttonTextArray = ["Start Your Journey","Success Inspiration","Get It Done!","Not Trying Is Failing"," Much effort, Much prosperity.","Know You Can Do It.","Focus","Persistence","Failure is Part Of Learning.","Be Time Wealthy.","Everyone has to succeed.","Failure is not an option.","Determination","Time Rich","Have A Winning Day","Be Happy","Go For It!","Be The Tiger","Stick To It!","Don't Stress","Work Hard","Love Yourself!","Be Awesome!","Think Positive","Reach Your Goals","Dream It!","Believe It","Achieve It!","Carry On","Be Fearless","Make The Moment","Enjoy The Ride","Inspire Others","Stay Positive","Take Risks","Keep Moving Forward","Always Believe","Stay Ready","Love Others","Enhance Lives","Be Inspirational","Be Healthly","Be Helpful","Live Well"]
var numberButton = 40
var numberCheck = 0
var product: SKProduct!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func btnRestore(sender: UIButton) {
}
@IBAction func btnGetTheGuide(sender: UIButton) {
let payment:SKPayment = SKPayment(product: product)
SKPaymentQueue.defaultQueue().addPayment(payment)
}
@IBAction func btnemoveAds(sender: UIButton) {
}
@IBAction func btnAnoterQuoteACTION(sender: UIButton) {
selectQuote()
changeButtonText ()
}
func selectQuote() {
numberQuote = Int(arc4random_uniform(40))
if numberQuote == numberCheck{
numberQuote = Int(arc4random_uniform(40))
if numberQuote == numberCheck && numberQuote != 0{
numberQuote = 0
}
else{
numberQuote = 1
}
}
printQuote()
}
func printQuote(){
lblQuotes.text = "\(quoteArray[numberQuote])"
}
func changeButtonText(){
numberButton = Int(arc4random_uniform(3))
btnAnotherQuote.setTitle("\(buttonTextArray[numberQuote])", forState: UIControlState.Normal)
}
}
那么我该如何解决这个问题呢?
最佳答案
实现SKPaymentTransactionObserver和SKProductsRequestDelegate的协议(protocol)方法
引用
对于 SKPaymentTransactionObserver https://developer.apple.com/library/prerelease/ios/documentation/StoreKit/Reference/SKPaymentTransactionObserver_Protocol/index.html
对于 SKProductsRequestDelegate:https://developer.apple.com/library/prerelease/ios/documentation/StoreKit/Reference/SKProductsRequestDelegate/index.html
注意:还有很多东西是缺失的,所以你也可以遵循一个很好的教程; http://www.raywenderlich.com/105365/in-app-purchases-tutorial-getting-started
编辑:在您的类中实现以下 2 个必需的方法将消除错误。
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
//Code here
}
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
//Code here
}
关于ios - View Controller 不符合 SKPaymentTransactionObserver、SKProductsRequestDelegate 的协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34004393/
我设置了应用内购买,这样当用户点击购买按钮时,会出现“请稍候” View 并将付款添加到付款队列中。这总是会导致队列的观察者立即回调,说交易进入了“购买”状态。 我的问题发生在用户返回主屏幕之前确认购
我有一个应用程序提供自动续订订阅的 IAP。 当应用程序启动时,会调用以下方法,有时会调用多次,但我不确定调用者或原因。 - (void)paymentQueue:(SKPaymentQueue *)
我正在尝试在 Swift 应用中实现应用内购买,这是一种消耗品应用内购买,产品 ID 为 productID 研究 使用 this answer ,我了解了应用内购买的基本模式,并尝试对其进行调整,就
我有一个 ObjC & Swift Mixed 项目,它使用 StoreKit 进行 IAP,类的定义如下: ... import StoreKit public class IAPManager:
我已经设置了一个 PurchaseViewController,它一直运行良好,除了多个应用商店登录,我意识到这是 SKPaymentQueue.defaultQueue().addTransacti
即使输入所需的代码后,我仍然收到错误消息。我缺少什么? class ViewController: UIViewController, SKPaymentTransactionObserver, SK
好吧,我正在遵循教程( http://stefansdevplayground.blogspot.com/2015/04/how-to-implement-in-app-purchase-for.ht
我有一个应用程序内购买来删除广告,但我只有一个错误阻止我编译我的代码。我确定我有必要的代码,但我认为缺少某些东西。谁能帮忙? 这是我的代码: import SpriteKit
我一直在测试应用程序内购买的代码,但在调用 updatedTransactions SKPaymentTransactionObserver 委托(delegate)方法时,我无法将交易状态设置为恢复
我正在尝试将托管内容添加为单一 View 应用的 IAP。但是,在编码时,我在 Xcode 7 中不断收到以下错误 “ View Controller 不符合 SKPaymentTransaction
所以我知道问题出在 IAP 的 ViewController 上,但不确定如何修复它。 我在 viewDidLoad 中添加了 SKPaymentQueue.defaultQueue().addTra
我正在使用测试用户(在沙箱中)测试 IAP,我有一个实现 SKPaymentTransactionObserver 协议(protocol)的类,当用户选择某个 TableView 单元格时,我启动支
在实现和测试委托(delegate)方法后,我们在 Itunes connect 中不断收到此警告消息: These in-app purchases can’t be promoted on the
我是一名优秀的程序员,十分优秀!