简体   繁体   English

在MFMessageComposeViewController中更改绑定到发送按钮的动作

[英]Changing the action bound to the send button in MFMessageComposeViewController

I know it's not officially possible. 我知道这是不可能的。 I don't want to release it to the store, it's just a prototype. 我不想将其发布到商店,它只是一个原型。

I tried finding the button: 我试图找到按钮:

MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;

NSArray * allViewControllers = [messageController viewControllers];

for (UIViewController *viewController in allViewControllers)
{
    NSArray *allSubviews = [viewController.view subviews];
    NSLog(@"class name: %@", viewController.class);

    for(UIView *view in allSubviews)
    {
        if([view isMemberOfClass:[UIButton class]])
        {
            UIButton *button = (UIButton *)view;
            NSLog(@"title: %@", button.titleLabel.text);
        }
    }
}

But nothing worked, so is it possible to change that send button? 但是没有任何效果,因此可以更改发送按钮吗? A sort of a hack? 是一种骇客吗? or importing a private header? 或导入私有标头?

Thanks you. 谢谢。

Update: 更新:

Tried the following: 尝试了以下内容:

NSArray *allSubviews = [[messageController toolbar] subviews];

for(UIView *view in allSubviews)
{
    if ([view isKindOfClass:[UIToolbar class]])
    {
        UIToolbar *navigationBar = (UIToolbar *)view;
        for(UIView *subview in navigationBar.subviews)
        {
            NSLog(@"%@", [subview subviews]);
            if([subview isMemberOfClass:[UIBarButtonItem class]])
            {
                UIBarButtonItem *button = (UIBarButtonItem *)view;
                NSLog(@"title: %@", button.title);
            }
        }

    }

Behind the hood, yes you can trick the label of Send Button. 是的,在引擎盖后面,您可以欺骗“发送按钮”的标签。

Officially it is not allowed, but for private use you can use following framework which is available on github. 正式禁止这样做,但是对于私人使用,您可以使用github上可用的以下框架。 https://github.com/nst/iOS-Runtime-Headers/tree/master/Frameworks/MessageUI.framework . https://github.com/nst/iOS-Runtime-Headers/tree/master/Frameworks/MessageUI.framework

Instead of default framework include this in your project. 在您的项目中包括默认框架,而不是默认框架。 And change whatever you want. 并更改您想要的任何内容。

If any query let me know i will show the code. 如果有任何疑问,请告诉我,我将显示代码。

I've never done this but here are some ideas to point you in the right direction. 我从来没有做过,但是这里有一些想法可以为您指明正确的方向。

MFMailComposeViewController is a UINavigationController . MFMailComposeViewController是一个UINavigationController The "Send" and "Cancel" buttons are actually in its navigation bar. “发送”和“取消”按钮实际上位于其导航栏中。 The navigation bar is a subview of the UINavigationController's view, rather than belonging to any of its children. 导航栏是UINavigationController's视图的子视图,而不是属于其任何子级。 You are logging the subviews of each child view, so you would never actually see the navigation bar since it is managed by the parent. 您正在记录每个子视图的子视图,因此您将永远不会看到导航栏,因为它是由父视图管理的。

Try logging the subviews of the messageController.view , that should give you the navigation bar. 尝试记录messageController.view的子视图,这将为您提供导航栏。 The other thing is that you are checking for UIButton whereas you may want to be checking for a UIBarButtonItem . 另一件事是您要检查UIButton而您可能要检查UIBarButtonItem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用iPhone中的自定义按钮在MFMessageComposeViewController中执行按钮操作 - Performing the button action in MFMessageComposeViewController with custom button in iPhone MFMessageComposeViewController消息消失,并在按下发送按钮后无法发送(iOS 7) - MFMessageComposeViewController messages disappear and fail to send after send button is pressed (iOS 7) 使用MFMessageComposeViewController发送音频 - send audio with MFMessageComposeViewController 发送没有MFMessageComposeViewController的imessages - Send imessages without MFMessageComposeViewController MFMessageComposeViewController无法发送 - MFMessageComposeViewController fails to send MFMessageComposeViewController 取消按钮不起作用 - MFMessageComposeViewController cancel button not working MFMessageComposeViewController禁用添加收件人按钮 - MFMessageComposeViewController disable add recipients button 如何禁用MFMessageComposeViewController中的附件按钮? - How to disable attachments button in MFMessageComposeViewController? MFMessageComposeViewController 的取消按钮颜色 - MFMessageComposeViewController's cancel button color 如何在没有“ MFMessageComposeViewController”的情况下在iPhone上以编程方式发送SMS? - How to programmatically send SMS on the iPhone without “MFMessageComposeViewController ”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM