我正在试图弄清楚如何在我的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)
我的目标:
我试过了:
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) 我想实现一个imessage应用程序,但是对于消息框架是新手,而iMessage应用程序是一个新东西,没有太多资源.所以我正在关注WWDC视频并使用Apples为指南提供示例应用程序.
我有三个视图,MessageViewController它们处理几乎所有的功能,然后是a CreateViewController和a DetailsViewController.
我只是想创建一个MSMessage从CreateViewController并显示在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) 我能够将视频嵌入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视频.