iOS13 上的新共享表在其左上角显示了共享项目的预览/缩略图。
当使用 UIActivityViewController 共享 UIImage 时,我希望共享图像的预览/缩略图显示在那里(例如共享附加到内置邮件应用程序的图像时),但共享表显示的是我的应用程序图标。
需要什么代码/设置才能在共享表中显示正在导出的图像的缩略图?
我已经设置了 UIActivityViewController 如下:
let image = UIImage(named: "test")!
let activityVC = UIActivityViewController(activityItems: [image], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view
self.present(activityVC, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud) 我在 UINavigationController 内的 UIViewController 中设置了一个 UIButton 作为 rightBarButtonItem 并将 iOS13 上下文菜单关联到它。
长按按钮会按预期显示上下文菜单。
有没有办法通过点击按钮来显示上下文菜单(例如,通过为 .touchUpInside 事件添加目标)?
按钮/barButtonItem 设置如下:
let button = UIButton(type: .system)
button.setImage(UIImage(systemName: "plus"), for: .normal)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.rightBarButtonItem = barButton
let interaction = UIContextMenuInteraction(delegate: self)
button.addInteraction(interaction)
Run Code Online (Sandbox Code Playgroud)
上下文菜单定义如下:
extension ViewController: UIContextMenuInteractionDelegate {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
let importAction = UIAction(title: "Import", image: UIImage(systemName: "folder")) { action in }
let createAction = UIAction(title: "Create", …
Run Code Online (Sandbox Code Playgroud) 在我开发的其中一个应用程序中,我使用共享扩展来导入钱包通行证 (PKPass)。
在 iOS 13(包括最新的 beta 8)上,当从 iOS 邮件应用程序中调用共享扩展时,该扩展没有接收到预期格式(URL)的数据。
这是来自共享扩展的 ShareViewController 的相关片段:
if let inputItems = self.extensionContext?.inputItems,
let inputItem = inputItems.first as? NSExtensionItem,
let attachments = inputItem.attachments,
let attachment = attachments.first,
attachment.hasItemConformingToTypeIdentifier("com.apple.pkpass" as String){
attachment.loadItem(forTypeIdentifier: "com.apple.pkpass" as String, options: nil) { data, error in
print ("data: \(String(describing: data))")
}
Run Code Online (Sandbox Code Playgroud)
在 iOS 12(最新版本)上,这也适用于 iOS 邮件应用程序中的附件(除了文件应用程序中的文件);data 包含一个可选的 URL。上面的打印语句在控制台中显示如下:
data: Optional(file:///var/mobile/Library/Mail/8EF174CF-68B9-414E-A166-D04C9DBE020E/INBOX.imapmbox/Attachments/13846/2/Attachment-1.pkpass)
Run Code Online (Sandbox Code Playgroud)
在 iOS 13 (beta 8) 上,在 iOS Mail 应用程序中,数据包含一个可选的 _NSItemProviderSandboxedResource。上面的打印语句在控制台中显示如下:
data: Optional(<_NSItemProviderSandboxedResource: 0x2839aa9e0>)
Run Code Online (Sandbox Code Playgroud)
这似乎只影响邮件应用程序。在“文件”应用程序中,数据按预期保留了一个 URL。
这是一个错误(实际上我已经在 beta 4 中使用反馈助手报告了这个问题)还是 iOS 13 引入的一些新的安全功能?在这种情况下,如何访问附件的 …
在iOS 12设备上使用Xcode 11(测试版3)构建和运行Core Data项目(使用Xcode 10创建)时,出现以下警告:
CoreData:注释:无法在路径'/var/containers/Bundle/Application/7908B3F7-66BC-4931-A578-6A740CBFB37D/TestOMO.app/TestOMO.momd/TestOMO.omo'上加载优化的模型
如果没有警告
我的应用程序似乎可以正常运行,并且没有崩溃,因此我不确定收到此警告的认真程度。尽管如此,我当然希望摆脱它。
有许多与此核心数据注释相关的帖子,但大多数与Google Maps相关或未答复。
我创建了一个新项目,以消除与我自己的项目相关的问题的其他原因,并使其易于重现,如下所示:
清理构建文件夹或删除派生数据没有帮助。
我试图建立一个UITableView
使用新的章节UITableViewDiffableDataSource
内UITableViewController
。
除了设置节标题,一切似乎都可以正常工作。
根据Apple的文档,UITableViewDiffableDataSource
符合UITableViewDataSource
,因此我期望这是可能的。
我试过了:
但是两种方法都不会导致结果(Xcode 11和iOS13 beta 3)。
当前是否可以使用设置节标题的方法UITableViewDiffableDataSource
?
我试图通过在特定文件夹中的所有(大约 200 个)通行证上运行循环并为每个通行证调用generateBestRepresentation(for:) 来创建多个钱包通行证(.pkpass)的缩略图。
\n\n这是代码:
\n\nlet passesDirURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("Passes")\nlet size = CGSize(width: 1600, height: 1600)\nlet scale = UIScreen.main.scale\n\nif let passURLs = try? FileManager.default.contentsOfDirectory(\n at: self.passesDirURL,\n includingPropertiesForKeys: nil,\n options: .skipsHiddenFiles\n ),\n !passURLs.isEmpty {\n for passURL in passURLs {\n // Create the thumbnail request.\n let request = QLThumbnailGenerator.Request(\n fileAt: passURL,\n size: size,\n scale: scale,\n representationTypes: .thumbnail\n )\n\n // Retrieve the singleton instance of the thumbnail generator and generate the thumbnails.\n let generator = QLThumbnailGenerator.shared\n generator.generateBestRepresentation(for: request) { …
Run Code Online (Sandbox Code Playgroud) 在更改视图中的一些其他数据后刷新视图时,我正在经历以下分段控件选定段中的文本动画:
这是错误/功能还是有办法消除这种行为?
这是重现效果的代码:
import SwiftUI
struct ContentView: View {
let colorNames1 = ["Red", "Green", "Blue"]
@State private var color1 = 0
let colorNames2 = ["Yellow", "Purple", "Orange"]
@State private var color2 = 0
var body: some View {
VStack {
VStack {
Picker(selection: $color1, label: Text("Color")) {
ForEach(0..<3, id: \.self) { index in
Text(self.colorNames1[index]).tag(index)
}
}.pickerStyle(SegmentedPickerStyle())
Text("Color 1: \(color1)")
}
.padding()
VStack {
Picker(selection: $color2, label: Text("Color")) {
ForEach(0..<3, id: \.self) { index in
Text(self.colorNames2[index]).tag(index)
}
}.pickerStyle(SegmentedPickerStyle())
Text("Color 2: \(color2)") …
Run Code Online (Sandbox Code Playgroud)