MFMailCompose Custom buttons

痞子三分冷 提交于 2019-12-14 03:06:26

问题


        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.


回答1:


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

}

Hope this helped :)



来源:https://stackoverflow.com/questions/8714802/mfmailcompose-custom-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!