gpt4 book ai didi

ios - iOS 10 中的 UIActivityViewController

转载 作者:可可西里 更新时间:2023-11-01 01:32:54 26 4
gpt4 key购买 nike

有人知道如何在 iOS 10 中使用 UIActivityView 吗?现在由于某种原因在 Swift 3.0 中它会编译和构建但是当应用程序在按下共享按钮后运行时使用以下代码导致应用程序崩溃......它在 iOS 9.3 和 Swift 2.0 中完美运行。

如代码第 6 行的注释中指定或 let objectsToShare = [textToShare] as! AnyObject 导致 Thread1:信号 SIGABRT 和应用程序崩溃

@IBOutlet weak var detailDescriptionLabel: UITextView!

@IBAction func share(_ sender: AnyObject) {
let textToShare = detailDescriptionLabel.attributedText

let objectsToShare = [textToShare] as! AnyObject
// line above causes app crash in iOS 10 - compiled and built
// error is "Thread1: signal SIGABRT"

let activityVC = UIActivityViewController(activityItems: objectsToShare as! [AnyObject], applicationActivities: nil)

activityVC.popoverPresentationController?.sourceView = (sender as! UIView)
self.present(activityVC, animated: true, completion: nil)
}


class ActivityForNotesViewController: UIActivityViewController {

internal func _shouldExcludeActivityType(_ activity: UIActivity) -> Bool {
let activityTypesToExclude = [
//insert UIActivity here
]

if let actType = activity.activityType {
if activityTypesToExclude.contains(actType) {
return true
}
else if super.excludedActivityTypes != nil {
return super.excludedActivityTypes!.contains(actType)
}
}
return false
}
}

如果有人能帮助我,我将不胜感激。

最佳答案

let objectsToShare = [textToShare]

let activityVC = UIActivityViewController(activityItems: objectsToShare , applicationActivities: nil)

应该是这样使用的。

关于ios - iOS 10 中的 UIActivityViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38979638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com