我开发了一个带有功能的IOS应用程序,它将带有源代码生成文本的SMS发送给源代码生成的电话接收者.
对于~100个用户来说,它可以工作好几个月,但现在我遇到了一个有趣的错误:当SMS UI出现时,而不是我传递给它的电话号码,有一个"好友名称"文本,而不是SMS,消息类型是MMS.它发生在带有IOS 7的iPhone 4上.
我使用它的方式(电话号码是NSString):
NSArray* recipients = [NSArray arrayWithObject:telephoneNumber];
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = message;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
有没有更多的设置,方法调用(...)来避免这种奇怪的行为?
非常感谢!
我想自定义MFMessageComposeViewController导航栏的特定图像和状态栏的简单白色,导航栏的标题和取消按钮。我唯一不能做的就是更改取消按钮的颜色。这是我的实现:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]];
MFMessageComposeViewController *sms = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
sms.body = string;
sms.recipients = number;
sms.messageComposeDelegate = self;
[self presentViewController:sms animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过,[sms.navigationBar setTintColor:[UIColor whiteColor]];但它不起作用。
编辑
我终于找到了一个解决方案:只需在最后一行下添加这行代码[UINavigationBar appearance]:
[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil].tintColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud) 使用iOS 11的iPhone 8和iPhone 8 plus无法从iOS应用程序内部打开MFMessageComposeViewController.他们有时打开黑屏.
是否有其他人在运行iOS 11的iPhone 8上遇到此问题并找到了解决方案?请帮忙.
我设法仅在运行iOS 11的iPhone 8上重现此问题.
提前致谢!
我正在尝试为我的应用启用 MessageUI 中的相机和应用按钮。我在 Apple 的文档中没有找到关于如何执行此操作的任何地方。有任何想法吗?谢谢!
更新:我disableUserAttachments()在 Apple 的文档中找到了一个函数,这与我正在寻找的相反。Apple 特别表示,此功能会禁用消息视图中的相机/附件按钮。我的项目中没有此代码,它仍然处于禁用状态。我还没有找到像 enableUserAttachments 这样的东西,这是我认为我需要的。任何想法表示赞赏。

xcode messageui imessage mfmessagecomposeviewcontroller swift
嗨,我正在使用MFMessageComposeViewController在我的iOS项目中发送短信,我的代码如下所示,
MFMessageComposeViewController *message = [[MFMessageComposeViewController alloc] init];
message.delegate = self;
message.recipients = [NSArray arrayWithObject:@"xxxxxx"];
message.body = @"blha blah,,,,";
[self presentModalViewController:message animated:YES];
Run Code Online (Sandbox Code Playgroud)
并且在我的代码中我定义了MFMessageComposeViewControllerDelegate方法didFinishWithResult但是当任务完成时,控件没有调用这个didFinishWithResult委托方法.可能是什么问题?
任何帮助都提前感谢.
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc]init];
[UINavigationBar appearance].barTintColor = [UIColor colorWithRed:0.0f/255.0f green:127.0f/255.0f blue:254.0f/255.0f alpha:1.0];
[[messageController navigationBar] setTintColor: [UIColor whiteColor]];
messageController.messageComposeDelegate = self;
[messageController setBody:message];
[messageController navigationBar].translucent =NO;
[messageController.navigationBar setBarTintColor:[UIColor colorWithRed:0.0f/255.0f green:127.0f/255.0f blue:254.0f/255.0f alpha:1.0]];
// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:^{
[messageController navigationBar].translucent = NO;
}];
Run Code Online (Sandbox Code Playgroud)
我一直在使用此代码。请让我知道是否有任何遗漏。
我使用 ViewControllerRepresentable 来呈现 MFMessageComposeViewController,以便用户可以从我的应用程序发送文本。
然而,每次呈现视图时,它都非常有问题 - 元素随机消失,滚动关闭,并且屏幕闪烁。在 iOS 14.2 和 14.3 上测试。
这是代码:
import SwiftUI
import MessageUI
struct MessageView: UIViewControllerRepresentable {
var recipient: String
class Coordinator: NSObject, MFMessageComposeViewControllerDelegate {
var completion: () -> Void
init(completion: @escaping ()->Void) {
self.completion = completion
}
// delegate method
func messageComposeViewController(_ controller: MFMessageComposeViewController,
didFinishWith result: MessageComposeResult) {
controller.dismiss(animated: true, completion: nil)
completion()
}
}
func makeCoordinator() -> Coordinator {
return Coordinator() {} // not using completion handler
}
func makeUIViewController(context: Context) -> MFMessageComposeViewController { …Run Code Online (Sandbox Code Playgroud) mfmessagecomposeviewcontroller mfmailcomposeviewcontroller swiftui uiviewrepresentable uiviewcontrollerrepresentable
我试图截取我的应用程序的屏幕截图,然后将其发送给消息中的联系人.当我在我的照片库中查看屏幕截图时,截图很正常...但是当消息编辑器打开图像时,它会显示为"?" 像mime类型不正确.我正在使用UIImageJPEGRepresentation将图像转换为NSData.我究竟做错了什么?非常感谢
func screenShotMethod() {
if (messageComposer.canSendText()) {
// Obtain a configured MFMessageComposeViewController
//Create the UIImage
UIGraphicsBeginImageContext(view.frame.size)
view.layer.renderInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
//Save it to the camera roll
//UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
let messageComposeVC = messageComposer.configuredMessageComposeViewController()
//messageComposeVC.body = image
var imageData = UIImageJPEGRepresentation(image, 1.0)
messageComposeVC.addAttachmentData(imageData, typeIdentifier: "image/jpeg", filename: "My Image")
presentViewController(messageComposeVC, animated: true, completion: nil)
}
else
{
println("No good")
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个具有呼叫和消息功能的应用程序,我想检查是否安装了SIM卡因为它发出了"消息已发送成功"的警报
请帮帮我.
我正在尝试发送短信并设置控制器,但是我得到了一条错误消息'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <Ally.TextMessageController: 0x7fd5361278e0>.'我已经确保在我的故事板中我将它连接到TextMessageController所以我不太清楚是什么导致了崩溃.
class TextMessageController: UIViewController, MFMessageComposeViewControllerDelegate {
var phone: String?
override func viewDidLoad() {
super.viewDidLoad()
print(phone)
var messageVC = MFMessageComposeViewController()
messageVC.body = "Hey I need help, are you available";
messageVC.recipients = ["555555555"]
messageVC.messageComposeDelegate = self;
presentViewController(messageVC, animated: false, completion: nil)
// Do any additional setup after loading the view.
}
func canSendText() -> Bool {
return MFMessageComposeViewController.canSendText()
}
func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) { …Run Code Online (Sandbox Code Playgroud) mfmessagecomposeviewcontroller ×10
ios ×7
iphone ×3
objective-c ×3
swift ×3
xcode ×2
imessage ×1
messageui ×1
mfmailcomposeviewcontroller ×1
screenshot ×1
sdk ×1
sms ×1
swiftui ×1