如何创建“添加到苹果钱包"使用PKAddPassButton进行本地化传递的按钮 [英] How to create "Add to apple wallet" button using PKAddPassButton for passes with localisation

查看:288
本文介绍了如何创建“添加到苹果钱包"使用PKAddPassButton进行本地化传递的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS项目中,我有一个屏幕,允许用户创建苹果通行证并将其添加到钱包.苹果建议使用PKAddPassButton创建添加到苹果钱包"按钮.当我尝试使用以下代码创建Apple Pass时:

In my iOS project I have a screen which allows the user to create apple passes and add it to the wallet. Apple recommends creating "Add to apple wallet" button using PKAddPassButton. When I tried creating apple pass using following code:

let passButton =  PKAddPassButton(addPassButtonStyle: PKAddPassButtonStyle.black)
passButton.frame = CGRect(x:45.0, y: 340.0, width: 320, height: 50)
view.addSubview(passButton)

按钮有几个问题:

  1. 钱包图像不可见.
  2. 即使在设备级别更改语言后,也不会对文本进行本地化.

我应该使用一些自定义的UIButton来实现这一点吗?任何帮助表示赞赏.

Should I use some custom UIButton to achieve this? Any help is appreciated.

推荐答案

我找到了答案,当时我正在模拟器上测试代码.如果用户在设置中更改了设备语言,它将直接反映在添加到Apple钱包按钮"中.

I found the answer, I was testing the code on simulator.When tested the same on device it worked and also localisation is taken care by iOS. If the user changes device language in settings it directly gets reflected in "Add to Apple wallet button".

这篇关于如何创建“添加到苹果钱包"使用PKAddPassButton进行本地化传递的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆