要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
EmptyDataKit 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile:
pod "EmptyDataKit"
此框架也已添加到名为 SBAnimation
的其他仓库中,且在 SBAnimation
中的示例更清晰。所以很抱歉,我不想用 SBAnimation
替换这个示例。因此,我也在这里展示了那个示例的截图。如果您需要,可以前往那里阅读我的代码。
在需要使用 EmptyDataKit 时添加代码,例如在 ViewDidLoad
__weak typeof(self) weakSelf = self;
EmptyDataKit *kit = [[EmptyDataKit alloc] initWithEdk_Image:[UIImage imageNamed:@"common_pic_loadFail"] edk_Message:@"aaa" edk_reloadHandler:^{
[weakSelf getData];
}];
kit.edk_error_image = [UIImage imageNamed: @""];
kit.edk_error_message = @"网络错误";
self.tableView.emptyKit = kit;
我们还提供了一个枚举类,如下所示:
typedef NS_ENUM(NSUInteger ,EmptyDataType) {
EDK_Loading, // if there is a LoadingView, use this ,and also this is a default status.
EDK_None, // if there is some data, use this.
EDK_Empty, // if there is no data, use this.
EDK_Error // if there is some error such as network, use this.
};
这样,如果您想显示不同的图片或描述文字,可以使用这个。在您使用这个表格视图或收藏视图的 reloadData
方法之前。
ProgramerSunny,[email protected]
EmptyDataKit 是在 MIT 许可下可用的。请参阅 LICENSE 文件以获取更多信息。