![](/img/trans.png)
[英]Performing the button action in MFMessageComposeViewController with custom button in iPhone
[英]Changing the action bound to the send button in MFMessageComposeViewController
我知道這是不可能的。 我不想將其發布到商店,它只是一個原型。
我試圖找到按鈕:
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);
}
}
}
但是沒有任何效果,因此可以更改發送按鈕嗎? 是一種駭客嗎? 或導入私有標頭?
謝謝。
更新:
嘗試了以下內容:
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);
}
}
}
是的,在引擎蓋后面,您可以欺騙“發送按鈕”的標簽。
正式禁止這樣做,但是對於私人使用,您可以使用github上可用的以下框架。 https://github.com/nst/iOS-Runtime-Headers/tree/master/Frameworks/MessageUI.framework 。
在您的項目中包括默認框架,而不是默認框架。 並更改您想要的任何內容。
如果有任何疑問,請告訴我,我將顯示代碼。
我從來沒有做過,但是這里有一些想法可以為您指明正確的方向。
MFMailComposeViewController
是一個UINavigationController
。 “發送”和“取消”按鈕實際上位於其導航欄中。 導航欄是UINavigationController's
視圖的子視圖,而不是屬於其任何子級。 您正在記錄每個子視圖的子視圖,因此您將永遠不會看到導航欄,因為它是由父視圖管理的。
嘗試記錄messageController.view
的子視圖,這將為您提供導航欄。 另一件事是您要檢查UIButton
而您可能要檢查UIBarButtonItem
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.