如何以编程方式启动uibarbuttonitem点击事件 [英] How to fire uibarbuttonitem click event programmatically

查看:180
本文介绍了如何以编程方式启动uibarbuttonitem点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 UIActionSheet

UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
                                                              delegate:self
                                                     cancelButtonTitle: @"cancel"
                                                destructiveButtonTitle: @"OK"
                                                     otherButtonTitles: nil];
          [action showInView:self.view];
          [action release];

UIActionSheet中的取消按钮事件我想触发一个 UIBarButtonItem 的事件,这在我看来。

On the event of the cancel button in the UIActionSheet I want to fire the event of a UIBarButtonItem, which is in my view.

我的问题是如何在 UIActionSheet 委托方法中触发按钮事件(不触摸按钮) / p>

My question is how can I fire the button event(without touching the button) in the UIActionSheet delegate method

推荐答案

不知道当前的按钮项目操作,您可以这样调用:

Not knowing the current bar button item action you can invoke it this way:

[barButtonItem.target performSelector:barButtonItem.action]

这将会带来未知选择器编译器警告,但这可能是解决

This will however bring "unknown selector" compiler warning, but this may be worked around.

这篇关于如何以编程方式启动uibarbuttonitem点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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