【发布时间】:2012-12-30 18:13:45
【问题描述】:
根据第2版的official FAQ根据用户选择的共享者自定义您的文本/内容,您需要:
- 来自 SHKActionSheet 的子类并覆盖 dismissWithClickedButtonIndex
- 设置新的子类名称 配置器(在 (Class)SHKActionSheetSubclass 中返回它;)。
这对我不起作用。但更重要的是:我把
NSLog(@"%@", NSStringFromSelector(_cmd));
在 (Class)SHKActionSheetSubclass 中查看它是否被调用。它不是 ;(( 所以 ShareKit 不关心这个配置选项...... 以前有人用过这个吗?
谢谢!
UPD1:我在这里放了一些代码。
这是我的子类 ITPShareKitActionSheet 的样子。根据文档,我需要覆盖dismissWithClickedButtonIndex:animated:,但要跟踪我的课程是否被调用,我还需要覆盖actionSheetForItem::
+ (ITPShareKitActionSheet *)actionSheetForItem:(SHKItem *)item
{
NSLog(@"%@", NSStringFromSelector(_cmd));
ITPShareKitActionSheet *as = (ITPShareKitActionSheet *)[super actionSheetForItem:item];
return as;
}
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animate
{
NSLog(@"%@", NSStringFromSelector(_cmd));
NSString *sharersName = [self buttonTitleAtIndex:buttonIndex];
[self changeItemForService:sharersName];
[super dismissWithClickedButtonIndex:buttonIndex animated:animate];
}
当用户按下“分享”按钮时,我在代码中创建了一个操作表:
- (IBAction)shareButtonPressed:(id)sender
{
// Create the item to share
SHKItem *item = [SHKItem text:@"test share text"];
// Get the ShareKit action sheet
ITPShareKitActionSheet *actionSheet = [ITPShareKitActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showInView:self.view]; // showFromToolbar:self.navigationController.toolbar];
}
当我运行此代码时,按“共享”按钮并选择我希望在日志中获得两行的任何共享者:
-
actionSheetForItem:- 自定义操作表已创建 -
dismissWithClickedButtonIndex:animated:- 自定义机制 进程操作表的按下按钮被调用。
但由于某种原因,我只记录了第一行。
【问题讨论】:
标签: objective-c subclass sharekit