Mastering
 share sheet preview

6a55a7fb19c1fa78e86ddca7a69db088?s=47 Yuka Ezura
November 11, 2019

Mastering
 share sheet preview

6a55a7fb19c1fa78e86ddca7a69db088?s=128

Yuka Ezura

November 11, 2019
Tweet

Transcript

  1. 22.

    -1-JOL.FUBEBUB An object that contains metadata about a URL https://developer.apple.com/documentation/linkpresentation/lplinkmetadata

    •var originalURL: URL? •var url: URL? •var title: String? •var iconProvider: NSItemProvider? •var imageProvider: NSItemProvider? •var videoProvider: NSItemProvider? •var remoteVideoURL: URL?
  2. 23.

    class ShareActivityItemSource: NSObject, UIActivityItemSource { func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) ->

    LPLinkMetadata? { linkMetadata } func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any { placeholder } func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? { item } }
  3. 24.

    class ShareActivityItemSource: NSObject, UIActivityItemSource { func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) ->

    LPLinkMetadata? { let linkMetadata = LPLinkMetadata() linkMetadata.title = "custom title" linkMetadata.iconProvider = NSItemProvider(contentsOf: imageURL) return linkMetadata } linkMetadata.iconProvider (or imageProvider) linkMetadata.title
  4. 25.

    class ShareActivityLazyLoadItemSource: NSObject, UIActivityItemSource { init(_ url: URL) { self.originalURL

    = url self.imageURL = saveImageInTemporaryDir(#imageLiteral(resourceName: "ezura"), fileName: "shareImage")! super.init() linkMetadata.title = "placeholder title" linkMetadata.originalURL = originalURL linkMetadata.iconProvider = NSItemProvider(contentsOf: imageURL) linkMetadata.imageProvider = NSItemProvider(contentsOf: imageURL) metadataProvider.startFetchingMetadata(for: originalURL) { [linkMetadata] metadata, error in linkMetadata.title = metadata?.title linkMetadata.url = metadata?.url linkMetadata.originalURL = metadata?.originalURL linkMetadata.iconProvider = metadata?.iconProvider linkMetadata.imageProvider = metadata?.imageProvider } } func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? { return linkMetadata }
  5. 28.

    3FDBQ w ϙΠϯτ1SFWJFX͞ΕΔίϯςϯπͷ༏ઌ౓ 6*"DUJWJUZ*UFN4PVSDF5FYU63-%BUB 6**NBHF౳  1SFWJFX͍ͨ͠ίϯςϯπΛ6*"DUJWJUZ*UFN4PVSDFܦ༝Ͱ౉͢  ෳ਺ͷ6*"DUJWJUZ*UFN4PVSDF͕͋Δ৔߹͸ઌউͪ 

    w ϙΠϯτ-1-JOL.FUBEBUB w -1-JOL.FUBEBUBʹλΠτϧ΍ΞΠίϯ౳ͷ৘ใΛೖΕΔ w ্هΛ6*"DUJWJUZ*UFN4PVSDFͷϝιουܦ༝Ͱ౉͢ ஫ҙ4IBSFઌʹ΋-1-JOL.FUBEBUB͸౉͞ΕΔ