Paypal IOS SDK acceptCreditCards崩溃

时间:2017-07-04 16:12:42

标签: ios swift paypal paypal-sandbox

有一个非常小众的问题,我已经在示例项目中实现了PayPal ios SDK,但是当我将import UIKit @IBDesignable class CustomTextField: UITextField { @IBInspectable var prefix : String = "" @IBInspectable var removePrefixOnEditing : Bool = true override init(frame: CGRect) { super.init(frame: frame) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func awakeFromNib() { super.awakeFromNib() self.addTarget(self, action: #selector(setCurrencyLabelPosition), for: .editingDidEnd) self.addTarget(self, action: #selector(removePrefix), for: .editingDidBegin) } func removePrefix(){ if self.attributedText != nil { if(self.removePrefixOnEditing) { self.defaultTextAttributes = [NSFontAttributeName : UIFont.systemFont(ofSize: 20)] let prefixRange = NSString(string: (self.attributedText?.string)!).range(of: prefix) if(prefixRange.location != NSNotFound) { self.attributedText = NSAttributedString(string: (self.attributedText?.string.replacingOccurrences(of: prefix, with: ""))!, attributes: self.defaultTextAttributes) } } } } func setCurrencyLabelPosition(){ if self.attributedText != nil { var fullText:String = "\((self.attributedText?.string)!)" if(NSString(string: (self.attributedText?.string)!).range(of: prefix).location == NSNotFound) { fullText = "\(prefix)\((self.attributedText?.string)!)" } //hacky part, seems to be a bug in UITextField self.defaultTextAttributes = [NSFontAttributeName : UIFont.systemFont(ofSize: 10)] self.attributedText = NSAttributedString(attributedString: self.changeFontForText(originalText: fullText, text: prefix, basicFont: UIFont.systemFont(ofSize: 20), newFont: UIFont.systemFont(ofSize: 12))) } } func changeFontForText(originalText:String,text:String,basicFont:UIFont, newFont:UIFont) -> NSMutableAttributedString { let resultAttributedString = NSMutableAttributedString(string: originalText, attributes: [NSFontAttributeName : basicFont]) let range = NSString(string: originalText).range(of: text) if(range.location != NSNotFound) { resultAttributedString.setAttributes([NSFontAttributeName:newFont], range: range) } return resultAttributedString } } 变量更改为true时。使用信用卡付款按钮显示,但如果您单击它,应用程序崩溃。我还需要添加哪些其他代码才能使其正常工作?

2 个答案:

答案 0 :(得分:1)

经过一些测试后,我意识到问题是相机权限。 Paypal需要使用你的相机,所以你必须将相机权限放在info.plist中。要执行此操作,只需在密钥$(PRODUCT_NAME) camera use下添加Privacy - Camera Usage Description

答案 1 :(得分:0)

在Paypal 2.15.1版之后,信用卡付款已弃用