全部, 我一直在阅读 Apple 文档,并且找到了显示通行证位和更改应用程序通行证的信息。但是有没有办法将 .pass zip 存储在 XCODE 中并显示在弹出 View Controller 中?
我已经弄明白了,但是我没有用。
有什么建议吗??
var pkfile : NSData = NSData(contentsOfFile: "Event.pkpass")!
var pass : PKPass = PKPass(data: pkfile, error: nil)
let vc = PKAddPassesViewController(pass: pass)
self.presentViewController(vc, animated: true, completion: nil)
最佳答案
我是这样做的:
var filePath = NSBundle.mainBundle().pathForResource("Event", ofType:"pkpass")
var pkfile : NSData = NSData(contentsOfFile: filePath!)!
var pass : PKPass = PKPass(data: pkfile, error: nil)
let vc = PKAddPassesViewController(pass: pass) as PKAddPassesViewController
self.presentViewController(vc, animated: true, completion: nil)
并确保在 build Settings/Copy Bundle Resources 中设置了 pkpass 文件。
希望这对某人有帮助。
关于swift - 存折,在应用程序中显示一个 .pass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28744981/