在我的应用中,我想分享当前的歌曲和艺术家,然后是专辑封面。这是我的代码:
var sharingItems = [AnyObject]()
let currentSong = musicPlayer.nowPlayingItem?.title
let currentArtist = musicPlayer.nowPlayingItem?.artist
let artwork = musicPlayer.nowPlayingItem?.artwork
let artworkImage = artwork?.imageWithSize(CGSizeMake(100, 100))
let shareText = "Now playing \(currentSong!) by \(currentArtist!) via Ryan's awesome app"
sharingItems.append(shareText) //text first, then image
sharingItems.append(artworkImage!)
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypeAddToReadingList, UIActivityTypeAssignToContact, UIActivityTypeOpenInIBooks, UIActivityTypePrint, UIActivityTypeSaveToCameraRoll]
self.presentViewController(activityViewController, animated: true, completion: nil)
当我选择共享选项(如Messges)时,图像位于TextField中的文本之前。如果图像在数组中是最后一个,为什么它首先出现?