如何检查是否在PKAddPassesViewController中按下了取消或添加按钮 [英] How to check whether cancel or add button is pressed in PKAddPassesViewController

查看:68
本文介绍了如何检查是否在PKAddPassesViewController中按下了取消或添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,通行证会加载到PKAddPassesViewController中.有什么方法可以知道在视图上按下了哪个按钮.

//this method runs when user either click on the cancel or add button

-(void)addPassesViewControllerDidFinish: (PKAddPassesViewController*) controller
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

我想获取在PKAddPassesViewController中按下的按钮的标题.我已经尝试过下面的代码来访问标题,但我却得到了null.

NSLog(@"Title of button    %@",controller.navigationController.navigationItem.rightBarButtonItem.title);

解决方案

据我所知没有,但是您总是可以尝试检索刚刚添加的通行证:

- (PKPass *)passWithPassTypeIdentifier:(NSString *)identifierserialNumber:(NSString *)serialNumber;

如果添加了通行证,将返回通行证,否则返回nil-这有助于推断是否添加了新通行证.

请注意,除了添加外,右键还可能显示更新"(如果该通行证已经存在,但您的版本具有新数据),或者如果您尝试重新添加一个重复的通行证,则该按钮将被禁用. /p>

By default passes are loaded in PKAddPassesViewController. Is there any way to know which button is pressed on the view.

//this method runs when user either click on the cancel or add button

-(void)addPassesViewControllerDidFinish: (PKAddPassesViewController*) controller
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

I want to get the title of the button that is pressed in the PKAddPassesViewController. I have tried the below code to access the title but i am getting null.

NSLog(@"Title of button    %@",controller.navigationController.navigationItem.rightBarButtonItem.title);

解决方案

As far as I am aware there is not, but you could always try and retrieve the pass you have just added with:

- (PKPass *)passWithPassTypeIdentifier:(NSString *)identifierserialNumber:(NSString *)serialNumber;

This will return the pass if it was added and nil if not - this could help deduce whether or not a new pass was added.

Note that as well as adding, the right button could be displaying 'Update' (if the pass is already present but your version has new data), or be disabled if you are trying to re-add a duplicate pass.

这篇关于如何检查是否在PKAddPassesViewController中按下了取消或添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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