标签: msmessage

从MSMessagesAppViewController正确呈现UIAlertController

我正在试图弄清楚如何在我的iMessage应用扩展程序中显示UIAlertController一种风格UIAlertControllerStyleActionSheet.

问题是,当调用时,操作表显示在本机iMessage文本字段下方:

[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];

我该如何解决这个问题?

码:

UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Clear", nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *clear = [UIAlertAction actionWithTitle:NSLocalizedString(@"Clear", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
{
    [self clear];
}];

UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action)
{}];

[actionSheetController addAction:clear];
[actionSheetController addAction:cancel];

[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

objective-c ios msmessage

13
推荐指数
1
解决办法
1607
查看次数

如何在iOS消息扩展中发送和读取图像/视频?

我的目标:

  • 允许用户将视频片段发送(或附加)到消息中
  • 允许接收方在收到视频时读取(不播放)视频
  • 不使用其他服务器来托管这些消息或视频.换句话说,我希望在消息扩展框架内完成所有事情.

我试过了:

1)使用MSMessage:

private func insertVideoIntoMessage(usingUrl url: URL) {
    if let conversation = self.activeConversation {
        let layout = MSMessageTemplateLayout()

        layout.caption = "Some caption"
        layout.mediaFileURL = url                // Media file (video)

        let message = MSMessage()
        message.layout = layout            
        message.url = URL(string: "some url")

        conversation.insert(message, completionHandler: { error in
            if let error = error {
                print("Error:", error)
            }
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

我想让接收器读取媒体文件(视频).但是,它似乎不可能.

override func didSelect(_ message: MSMessage, conversation: MSConversation) { 
    // message doesn't seem to contain any media content …
Run Code Online (Sandbox Code Playgroud)

video ios imessage msmessage

8
推荐指数
0
解决办法
467
查看次数

如何在消息扩展中发送MSMessage?

我想实现一个imessage应用程序,但是对于消息框架是新手,而iMessage应用程序是一个新东西,没有太多资源.所以我正在关注WWDC视频并使用Apples为指南提供示例应用程序.

我有三个视图,MessageViewController它们处理几乎所有的功能,然后是a CreateViewController和a DetailsViewController.

我只是想创建一个MSMessageCreateViewController并显示在DetailsViewController..然后添加到数据.

但是,在尝试创建数据时,我遇到了崩溃.

@IBAction func createAction(_ sender: AnyObject) {
    //present full screen for create list
    self.delegate?.createViewControllerDidSelectAdd(self as! CreateViewControllerDelegate)        
}
Run Code Online (Sandbox Code Playgroud)

我试图传递的数据类型是结构中的字典:

struct data {
var title: String!
var date: Date!

var dictionary = ["title" : String(), "Array1" : [String](), "Array2" : [String]() ] as [String : Any]

}
Run Code Online (Sandbox Code Playgroud)

所以这里是如何建立的;

MessagesViewController

class MessagesViewController: MSMessagesAppViewController, {

// MARK: Responsible for create list button

func composeMessage(for data: …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3 ios10 msmessage

5
推荐指数
1
解决办法
918
查看次数

如何在MSMessage嵌入式视频ios 10中启用音频

我能够将视频嵌入MSMessage实例并发送它只是问题是音频自动静音.您可以看到它被消息泡泡右上方的一个小扬声器屏蔽了.我也在我的iphone上试了一下,没有沉默,仍然没有声音.

let message = MSMessage()

        let layout = MSMessageTemplateLayout()
        layout.caption = "Titans music video"

        let filePath =
            Bundle.main.path(forResource: "TitansVideo", ofType: "mov")


        let fileUrl = NSURL(fileURLWithPath: filePath!)
        let URL = fileUrl as URL
        layout.mediaFileURL = URL

        message.layout = layout


        let conversation = self.activeConversation

        conversation?.insert(message, completionHandler: {(error) in
            if let error = error {
                print(error)
            }
        })
Run Code Online (Sandbox Code Playgroud)

我尝试使用不同的视频文件无济于事.我找不到太多关于此的信息,我开始认为Apple不希望启用音频.这很奇怪,因为在ios 10 WWDC中,您可以类似地在消息气泡中播放音频/视频的iMessage中发送YouTube视频.

audio ios swift ios10 msmessage

5
推荐指数
0
解决办法
274
查看次数

标签 统计

ios ×4

msmessage ×4

ios10 ×2

swift ×2

audio ×1

imessage ×1

objective-c ×1

swift3 ×1

video ×1