测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released最后发布 | 2014年12月 |
由 Yujin Ariza、Paul Fleiner、Chad DePue 维护。
Whisper-iOS-SDK 允许您的用户通过几行代码在应用程序内创建 Whisper 内容。目前,我们支持从图像、数据、文件路径或 URL 创建 Whisper 贴文,并支持自定义文本叠加。
请注意,使用 SDK 的图像宽度至少为 640 像素,高度至少为 920 像素。
SDK 要求安装 Whisper 应用。如果未安装 Whisper 应用版本的 4.2 或更高版本,用户将被提示到 App Store 下载它。我们的应用程序仅支持 iOS 6.0 或更高版本。
手动创建 Whisper 分为两个步骤
首先,调用配置方法之一。这定义了菜单呈现的来源,可以是 UIView
或 UIBarButtonItem
。
[[WHPWhisperAppClient sharedClient] prepareWithView:view inRect:view.bounds];
接下来,调用创建方法之一,从四个数据源之一创建 Whisper:UIImage
、NSData
、NSString
或 NSURL
。
[[WHPWhisperAppClient sharedClient] createWhisperWithImage:image error:&error];
或者,您可以使用标准 Whisper 按钮,并将其添加到视图中
UIButton *whisperButton = [[WHPWhisperAppClient sharedClient] whisperButtonWithSize:kWHPWhisperAppClientButtonSize_Medium rounded:YES];
[self.view addSubView:whisperButton];
按下按钮时,按钮将通过调用 WHPWhisperAppClient
的代理属性中的协议方法来检索图像数据。您可以通过设置代理属性为您自己的类提供这些方法
[WHPWhisperAppClient sharedClient].delegate = self;
...
-(UIView *)whisperAppClientViewForMenuPresentation
{
return _view;
}
-(UIImage *)whisperAppClientSourceImageForWhisper
{
return _image;
}
请注意,您的代理类必须遵循 WHPWhisperAppClientDelegate
协议。
最后,将以下方法添加到应用程序的 AppDelegate.m
文件中,以便启用从 Whisper 应用程序的回调
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([WHPWhisperAppClient handleOpenURL:url sourceApplication:sourceApplication])
return YES;
return NO;
}
这将使您能够通过代理方法接收应用程序从 Whisper 贴文返回的通知
-(void)whisperAppClientDidReturnWithResult:(WHPPostResult)result
{
switch (result) {
case kWHPPostResult_Success:
NSLog(@"Whisper post succeeded!");
break;
case kWHPPostResult_Failed:
NSLog(@"Whisper post failed!");
break;
case kWHPPostResult_Canceled:
NSLog(@"Whisper was canceled");
break;
case kWHPPostResult_Invalid:
NSLog(@"Invalid input!");
break;
default:
break;
}
}
有一个示例项目演示了上述功能和一些其他属性。要运行示例项目,首先将仓库克隆,然后从示例目录中运行 pod install
。
宇金·阿尔西亚,[email protected]
Whisper-iOS-SDK 在 Apache 许可下可用。更多信息请参阅 LICENSE 文件。