【发布时间】:2016-06-03 12:09:10
【问题描述】:
以下代码来自 WWDC 2015 Session 702 Apple Pay Within Apps - Emporium:Apple Pay 的简单购物体验
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(ProductTableViewController.supportedNetworks) {
let button = PKPaymentButton(type: .Buy, style: .Black)
button.addTarget(self, action: #selector(ProductTableViewController.applePayButtonPressed), forControlEvents: .TouchUpInside)
button.center = applePayView.center
button.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin]
applePayView.addSubview(button)
}
我想知道我们是否可以在 IB 中创建这个按钮。
【问题讨论】:
-
只需将您的按钮添加到 PKPaymentButton 的子类
-
以前的版本支持apple pay,但是不支持这个按钮怎么办?这意味着您将如何在 xib 中初始化一个有条件地子类为 PKPaymentButton 的按钮?
标签: ios swift interface-builder applepay