下面的代码适用于iOS 9.x或更低版本,由于某种原因,如果iOS 10不起作用
if([MFMessageComposeViewController canSendText])
{
controller.body = message;
NSString *tel = pContact.tlc;
controller.recipients = pContact.tlc?@[tel]:nil;
controller.messageComposeDelegate = self;
controller.navigationBar.tintColor = [UIColor whiteColor];
controller.navigationBar.barTintColor = [UIColor blueColor];
[self presentViewController:controller animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
它是破碎还是做了一些改变.不知道这里遗漏了什么.我在黑暗中(漆黑)
编辑:我试图在一个新的空单视图项目上使用一些测试代码,我遇到了同样的问题.
@IBAction func SMS(_ sender: AnyObject) {
let composeVC = MFMessageComposeViewController()
composeVC.messageComposeDelegate = self
// Configure the fields of the interface.
composeVC.recipients = ["5555555555"]
composeVC.body = "Hello from California!"
composeVC.navigationBar.tintColor = UIColor.green
composeVC.navigationBar.barTintColor = UIColor.purple
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
} …Run Code Online (Sandbox Code Playgroud)