gpt4 book ai didi

iphone - 在我的应用程序中包含电子邮件应用程序时出现问题

转载 作者:行者123 更新时间:2023-12-03 19:45:21 27 4
gpt4 key购买 nike

按下按钮时,将显示 MFMailComposeViewController

到目前为止我已经完成了。

我的问题是:

  1. 是否可以禁止按下取消按钮时弹出的操作表?
  2. 是否可以将收件人主题字段设置为不可编辑?
  3. 我想将左栏按钮更改为返回

我怎样才能做到这些?

- (IBAction)questionButtonPressed:(id)sender {
email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;

// Subject
[email setSubject:@"Testing"];

// Optional Attachments
NSData *artwork = UIImagePNGRepresentation([UIImage imageNamed:@"albumart.png"]);
[email addAttachmentData:artwork mimeType:@"image/png" fileName:@"albumart.png"];

// Body
//[email setMessageBody:@"This is the body"];

// Present it
[self presentModalViewController:email animated:YES];
}

最佳答案

是的,这三个都是可能的,但是#2 要么需要使用私有(private) API 要么需要一些黑客技术。我采用了子类化 MFMailComposeViewController 的方法,如下

// file: CustomMailComposeViewController.h
@interface CustomMailComposeViewController : MFMailComposeViewController {

}
@end

// file ustomMailComposeViewController.m
#import "CustomMailComposeViewController.h"
@implementation CustomMailComposeViewController

-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

//Here we replace the cancel button with a back button (Question #3)
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)];
self.navigationBar.topItem.leftBarButtonItem = backButton;
[backButton release];


//Here we disallow the user to change to to: cc: bcc: and subject: feilds (Question #2)
//Warning: the xxxField methods are undocumented private methods.
UITableViewController *vc = [self.viewControllers objectAtIndex:0];
UITableView *tvv = [vc view];
[[tvv toField] setUserInteractionEnabled:NO];
[[tvv ccField] setUserInteractionEnabled:NO];
[[tvv bccField] setUserInteractionEnabled:NO];
[[tvv multiField] setUserInteractionEnabled:NO];
[[tvv subjectField] setUserInteractionEnabled:NO];
}


//This is the target for the back button, to immeditally dismiss the VC without an action sheet (#1)
-(void) backButtonPressed:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
@end

要在代码中使用,您需要更改:[[MFMailComposeViewController alloc] init];到 [[CustomMailComposeViewController alloc] init];

关于iphone - 在我的应用程序中包含电子邮件应用程序时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4688790/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com