【问题标题】:Using StickerKit from Snapchat in Swift在 Swift 中使用来自 Snapchat 的 StickerKit
【发布时间】:2021-12-10 15:59:12
【问题描述】:

我正在尝试添加带有 url 照片内容的贴纸以发布到 snapchat。

snapAPI.startSending(snapContent) 显示 EXC_BAD_ACCESS

我收到警告:

警告:无法在进程中执行支持代码来读取 Objective-C 类数据。这可能会降低可用类型信息的质量。

     } else if category == "Share to Snapchat" {

        let url = URL(string: "")
        let data = try? Data(contentsOf: url!)
        let image = UIImage(data: data!)
        let stickerImage = image!
        let sticker = SCSDKSnapSticker(stickerImage: stickerImage)
        let snapContent = SCSDKNoSnapContent()
        snapContent.sticker = sticker
        snapAPI.startSending(snapContent)
        
    }

感谢任何帮助。

【问题讨论】:

  • 你是如何声明 snapAPI 的?

标签: ios xcode snapchat snapkit


【解决方案1】:

在 podfile 中导入这一行

pod 'SnapSDK', :subspecs => ['SCSDKLoginKit', 'SCSDKCreativeKit', 'SCSDKBitmojiKit']

然后导入这个-

import SCSDKCreativeKit
import SCSDKBitmojiKit
import SCSDKLoginKit

试试这个,对我有用。

let snapAPI = SCSDKSnapAPI()
let myURL = URL(string: "")
if let myData = try? Data(contentsOf: myURL!) {
    if let myImage = UIImage(data: myData) {
        let sticker = SCSDKSnapSticker(stickerImage: myImage)
        let snapContent = SCSDKNoSnapContent()
        snapContent.sticker = sticker
        snapAPI.startSending(snapContent) { (error: Error?) in
             if error == nil {
                     // Success
             }else{
                    // Check the error
             }
        }
    }
}

【讨论】:

  • 感谢您的回复。但它仍然显示错误。
  • @WhySoSerious33,我已经更新了我的答案。我正在这样做,并且效果很好。
  • 还是不行.. 还有什么要检查的?
  • 现在的错误是什么?收到警告?
  • snapAPI.startSending... "线程 1:EXC_BAD_ACCESS (code=2,address=0x16f3a3fb0)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-22
相关资源
最近更新 更多