gpt4 book ai didi

ios - UIActivity 自定义分享,触摸更多按钮时不显示缩略图图标

转载 作者:技术小花猫 更新时间:2023-10-29 11:23:01 31 4
gpt4 key购买 nike

我的应用支持 iOS 7+,我使用 UIActivity 图片大小:iPhone 60pt,iPad iOS 76pt,

当触摸更多按钮重新排序项目时,它无法在列表中显示图标。

Show share activities

enter image description here

代码如下:

class ZYShare {
class ActivityItem {
init() {
self.title = ""
self.icon = ""
}

var title: String?
var icon: String?
var type: ShareType = ShareTypeAny
}

class CommonActivity: UIActivity {
lazy var itemInfo = ActivityItem()

override func prepareWithActivityItems(activityItems: [AnyObject]) {
// do something

}

override func canPerformWithActivityItems(activityItems: [AnyObject]) -> Bool {
return true
}

override class func activityCategory() -> UIActivityCategory {
return UIActivityCategory.Action
}

override func activityType() -> String? {

return NSLocalizedString(itemInfo.title ?? "", comment: "")
}

override func activityTitle() -> String? {
return NSLocalizedString(itemInfo.title ?? "", comment: "")
}

override func activityImage() -> UIImage? {
println(itemInfo.icon)

if let icon = itemInfo.icon {
return UIImage(named: icon)
} else {
return nil
}
}

override func performActivity() {
ShareSDK.showShareViewWithType(itemInfo.type
, container: nil
, content: publishContent
, statusBarTips: false
, authOptions: authOptions
, shareOptions: options
, result: handle)

self.activityDidFinish(true)
}
}

class QQActivity: CommonActivity {
override init() {
super.init()

self.itemInfo.icon = "ShareToQQ"
self.itemInfo.title = "QQ"
self.itemInfo.type = ShareTypeQQ
}
}

class WeChatSessionActivity: CommonActivity {
override init() {
super.init()

self.itemInfo.icon = "ShareToWeChat"
self.itemInfo.title = "微信"
self.itemInfo.type = ShareTypeWeixiSession
}
}

class WeChatTimelineActivity: CommonActivity {
override init() {
super.init()

self.itemInfo.icon = "ShareToWeChatTimeLine"
self.itemInfo.title = "朋友圈"
self.itemInfo.type = ShareTypeWeixiTimeline
}
}

class QQSpaceActivity: CommonActivity {
override init() {
super.init()

self.itemInfo.icon = "ShareToQzone"
self.itemInfo.title = "QQ空间"
self.itemInfo.type = ShareTypeQQSpace
}
}
}

最佳答案

很老的问题,但也许解决方案对其他人也有帮助!

在您的UIActivity 子类中实现/覆盖该方法

- (UIImage *)activityImage {
return [UIImage imageNamed:@"Activity Icon"];
}

返回要在 UIActivityViewController 本身中显示的图像(正如您所做的那样)。

除了这个实现/覆盖方法

- (UIImage *)activitySettingsImage {
return [UIImage imageNamed:@"Activity Settings Icon"];
}

返回要在更多/设置 View 中显示的(其他或相同的)图像。

我没有在文档中找到第二种方法,但它不是 UIAction 的“_xx”方法,所以我猜它不是私有(private)的...

关于ios - UIActivity 自定义分享,触摸更多按钮时不显示缩略图图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27455481/

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