MFMailCompose自定义按钮 [英] MFMailCompose Custom buttons

查看:127
本文介绍了MFMailCompose自定义按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

        UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cancel.png"]]];
button.target = picker.navigationBar.topItem.leftBarButtonItem ;
button.action = picker.navigationBar.topItem.leftBarButtonItem.action;
picker.navigationBar.topItem.leftBarButtonItem=button;

您好,我正在尝试更改邮件撰写器按钮的样式.上面的代码确实改变了按钮的外观,但是该操作似乎丢失了.有什么想法可以克服这个问题吗?谢谢.

Hi folks, I'm trying to change the style of the buttons of the mail composer. The above code does change the look of the button, however the action seems to be lost. Any ideas how I can overcome this? Thanks.

推荐答案

此问题的解决方法非常简单.您将一个方法添加到此按钮,然后定义该方法中应该发生的事情.因此,首先,在声明按钮后放置此行.

The fix for this is fairly simple. You add a method to this button and then define what should happen in the method. So first, put this line after you declare your button.

[button addTarget:self action:@selector(aButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

这将添加单击/触摸按钮时要调用的方法.然后,在代码的后面,创建按钮将要调用的实际方法.

That will add a method to be called when the button is clicked/touched. Then, later in the code, you create the actual method that the button will be calling.

-(void)aButtonClicked:(id)sendr{
//Do stuff here

}

希望这会有所帮助:)

这篇关于MFMailCompose自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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