Swift UIActivityViewController在导出为文本时仅显示一项

时间:2019-06-28 03:01:27

标签: swift firebase firebase-realtime-database

我试图允许用户将项目列表导出到便笺,但是由于某种原因,它仅导出第一个项目,而不是导出整个列表,就像我希望的那样。这是我的尝试...

 guard let listId = list?.id else { return }

    let ref = Database.database().reference().child("lists").child(listId).child("list-items")
    ref.observe(.value) { (snapshot) in
        guard let dict = snapshot.value as? [String: Any] else { return }
        dict.forEach({ (key, value) in
            let itemRef = Database.database().reference().child("items").child(key)
            itemRef.observeSingleEvent(of: .value, with: { (snapshot) in

                guard let dictionary = snapshot.value as? [String: Any] else { return }

                guard let itemName = dictionary["item"] as? String else { return }

                let activityController = UIActivityViewController(activityItems: [itemName], applicationActivities: nil)
                self.present(activityController, animated: true, completion: nil)
            })
        })
    }

0 个答案:

没有答案