所有,我一直在阅读Apple文档,我已经找到信息来显示一个通行证并更改应用程序中的通行证.但有没有办法将.pass zip存储在XCODE中并显示在弹出视图控制器中?
我已经想到了这一点,但我没有工作.
任何建议?
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)
Run Code Online (Sandbox Code Playgroud)
我这样做了:
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)
Run Code Online (Sandbox Code Playgroud)
并确保在构建设置/复制包资源中设置了pkpass文件.
希望这有助于某人.
| 归档时间: |
|
| 查看次数: |
2526 次 |
| 最近记录: |