889 GitHub stars and counting — ChenYilong/CYLTableViewPlaceHolder is a Objective-C project TopGit is tracking across repositories on the platform. 一行代码完成“空TableView占位视图”管理
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This document is bilingual: body text is a two-column table with Chinese on the left and English on the right, the same content in each row; wide API tables give the full Chinese table first and then an English table with the same rows; code samples are shared, and their comments come in [CN] / [EN] pairs.
Headings read "中文 / English", and anchors join the two parts with --, for example #如何阅读-readme--how-to-read-this-readme. The "导航 / CONTENTS" table is generated by a script; do not edit it by hand.
Based on a UITableView category, so there is no pollution, and it is lighter than frameworks based on subclassing or inheritance.
2
Low coupling
You implement a custom placeholder view yourself and pass it through a protocol, so coupling is very low.
3
Simple, no learning cost
One line: just use cyl_reloadData instead of reloadData. It detects automatically whether addSubview and removeFromSuperview are needed, so you do not have to learn when to call add and remove.
4
Easy to use
Placeholder views are managed from the dataSource; the built-in CYLRefresh provides pull-down, pull-up and horizontal refresh.
5
CocoaPods support
Easy to integrate.
中文
English
(学习交流群:465239521)
(Study and discussion group: 465239521)
集成后的效果 / The result
使用 CYLTableViewPlaceHolder / Using CYLTableViewPlaceHolder
新增的 block API 支持 UITableView 和 UICollectionView,无需替换已有的 reloadData;旧的 cyl_reloadData 和 delegate API 保持可用。以下功能尚未包含在已发布的 1.1.0 中,使用时请集成包含这些改动的开发版本。
The new block API supports UITableView and UICollectionView and does not require replacing existing reloadData calls; the old cyl_reloadData and the delegate API keep working. The features below are not in the released 1.1.0; integrate a development version that contains them to use them.
#import <CYLTableViewPlaceHolder/CYLTableViewPlaceHolder.h>
[self.tableView cyl_placeholderViewBlock:^UIView *(UITableView *tableView) {
tableView.scrollEnabled = NO;
// [CN] 也可返回自定义视图
// [EN] You can also return a custom view
return [CYLPlaceholderView new];
} backToNormalBlock:^(UITableView *tableView) {
tableView.scrollEnabled = YES;
}];
// [CN] 取消自动占位;若占位视图正在显示,会调用恢复 block。
// [EN] Cancel the automatic placeholder; if one is showing, the restore block is called.
[self.tableView cyl_placeholderViewBlock:nil];
tableView.cyl_placeholderViewBlock({ tableView in
tableView.isScrollEnabled = false
return CYLPlaceholderView()
}, backToNormalBlock: { tableView in
tableView.isScrollEnabled = true
})
UICollectionView uses the same interface with the matching collection view block parameters. Emptiness is judged by the number of rows or items across all sections; with no data source, no placeholder is shown. reloadData, data source replacement, insertion, deletion, reload and move of sections, rows and items, batch updates, and iOS 15 reconfigure operations are supported. Updates are coalesced on the main queue; configure and update the UI on the main thread. The placeholder view is constrained to the frame layout guide and follows changes of the list's visible area and size.
If a block references the controller, use a weak reference to avoid a retain cycle. The images and localized text of the built-in CYLPlaceholderView are in CYLTableViewPlaceHolder.bundle, and you can adjust its imageView and textLabel. CYLPlaceholderStyle provides 51 offline images and CYLPlaceholderMessage provides 9 independently combinable messages; English, Simplified Chinese, Traditional Chinese, Japanese, Korean, Russian and Ukrainian are built in, chosen by the app language with a fallback to English. Initialize, or customize the image and text:
CYLPlaceholderView *offline =
[[CYLPlaceholderView alloc] initWithStyle:CYLPlaceholderStyleNoInternet
message:CYLPlaceholderMessageNoInternet];
CYLPlaceholderView *customText =
[[CYLPlaceholderView alloc] initWithStyle:CYLPlaceholderStyleWarning
text:@"请稍后再试"];
CYLPlaceholderView *customBoth =
[[CYLPlaceholderView alloc] initWithImage:myImage text:@"自定义提示"];
// [CN] 继续按需修改,例如 customBoth.textLabel.font 或 customBoth.imageView.tintColor。
// [EN] Keep customizing as needed, for example customBoth.textLabel.font or customBoth.imageView.tintColor.
let offline = CYLPlaceholderView(style: .noInternet, message: .noInternet)
let custom = CYLPlaceholderView(image: myImage, text: "自定义提示")
中文
English
传入 nil 图片或文字会隐藏相应内容。内置 Material 图标使用模板渲染,可通过 imageView.tintColor 自定义颜色;默认 Empty 图保持原样。可调用 imageForStyle:、imageNameForStyle: 和 localizedTextForMessage: 单独获取资源。内置图标及许可随资源包离线提供,不需要网络。示例中打开 Auto → Styles,点击样式和文案即可预览任意组合;也可输入自定义文案并体验自定义图片。
Passing a nil image or text hides that part. The built-in Material icons are rendered as templates, so their color can be changed through imageView.tintColor; the default Empty image stays as it is. Call imageForStyle:, imageNameForStyle: and localizedTextForMessage: to get the resources individually. The built-in icons and their licenses ship offline in the resource bundle and need no network. In the example, open Auto → Styles and tap styles and messages to preview any combination; you can also enter custom text and try a custom image.
资源包还提供 CYLPlaceholderNoResults、CYLPlaceholderNoInternet、CYLPlaceholderError、CYLPlaceholderWarning 和 CYLPlaceholderInbox 图标,分别适用于无搜索结果、无网络、错误、警告和空收件箱;它们不改变默认图片。可使用 UIImage 的 imageNamed:inBundle:compatibleWithTraitCollection: 从该资源包加载。图标来自 Google Material Design,许可及来源记录随资源包分发。
The resource bundle also provides the icons CYLPlaceholderNoResults, CYLPlaceholderNoInternet, CYLPlaceholderError, CYLPlaceholderWarning and CYLPlaceholderInbox, for no search results, no network, error, warning and an empty inbox respectively; they do not change the default image. Load them from the bundle with UIImage's imageNamed:inBundle:compatibleWithTraitCollection:. The icons come from Google Material Design, and their license and source records ship with the resource bundle.
也可以用字典或本地 plist 创建 FlatDesign 风格的图片与标题组合:
You can also create FlatDesign-style image and title combinations from a dictionary or a local plist:
The configuration keys are compatible with the serialized names of CYLTabBarItemTitle, CYLTabBarItemImage, CYLTabBarItemImageInsets, CYLTabBarItemImagePositionAdjustment and CYLTabBarItemTitlePositionAdjustment; the constants this library exports use the CYLPlaceholderItem prefix to avoid clashing with CYLTabBarController. An image can be a UIImage or an image name in the given bundle; when the bundle is nil, this library's resource bundle is used. An explicit image and title take priority over the preset style and message. Offsets accept [horizontal, vertical], a dictionary containing horizontal/vertical or x/y, and an NSValue passed from code; insets accept a four-element array, a top/left/bottom/right dictionary, or an NSValue. Static configuration errors are returned through NSError; animation loading errors are logged and fall back; no network resources are loaded.
In the normal state, text, icon and background colors accept a UIColor or #RGB, #RRGGBB, #RRGGBBAA; the text font accepts a UIFont, a point size, bold:18, or a dictionary containing name, size and weight. Image names also support system: SF Symbols on iOS 13 and later. The accessibility identifier, label and hint can be configured.
Set view.selected = YES to use CYLPlaceholderItemSelectedImage, CYLPlaceholderItemSelectedTitle and the selected-state colors and fonts; returning to the normal state keeps the changes made to the normal image, text and style before entering the selected state. The selected state sets VoiceOver's selected trait.
CYLPlaceholderItemDarkImage and CYLPlaceholderItemSelectedDarkImage accept a UIImage or a resource name and, on iOS 13 and later, choose the matching image by interface style; if only one of them is provided, it is used as the fallback for all appearances.
A badge can be hidden, a red dot, a number or custom text through showBadgeWithStyle:value:; numbers above 99 show as 99+, and a value not greater than 0 hides it. You can also set badgeValue directly (nil hides it, an empty string shows a red dot), badgeCenterOffset, and the font and color of badgeLabel. The badge becomes the placeholder view's accessibility value; the red dot uses the localized "New content". When the placeholder view itself is not an accessibility element, the badge label is read on its own; if the outer container is an accessibility element, the caller should provide a label or value that includes the badge's meaning. The Styles list in the example includes three badge previews.
The image and title are laid out as one centered unit; the item ports FlatDesign's image and title positioning, original image size and offset calculation, and long text wraps within the available width; with only an image or only text, it is centered on its own. The image and title can be offset separately. A local GIF can be passed through CYLPlaceholderItemGIFURL or CYLPlaceholderItemGIFFilePath; CYLPlaceholderItemGIFSize accepts [width, height], a size dictionary or an NSValue. A GIF plays once when it enters the window and stops when it leaves; with Reduce Motion enabled it stays on the first frame. GIF does not support network URLs. A GIF input can be at most 16 MB and 500 frames, and the decoded frames total at most 64 MB; an invalid or oversized resource logs an error and keeps the static placeholder image.
playPlaceholderAnimation, stopPlaceholderAnimation and showPlaceholderAnimationLastFrame replay, stop, or show the last frame; the stopped state is kept after leaving and re-entering the window. A Rive state machine has no general last frame, so its resting state is shown. setPlaceholderAnimationProgress: pauses and seeks Lottie or PAG to a progress between 0 and 1; setPlaceholderAnimationSpeed: sets a positive playback speed for Lottie. A method returns NO when the argument is invalid or the current backend does not support it; PAG seeks to the nearest frame. Explicit progress and speed are restored when a supported backend reloads.
Swift 桥接(LottieSwift/)加 Objective-C animator;不提供 Objective-C 版 Lottie 2.x
PAG / PAGEnterprise
libpag / libpag-enterprise ≥ 4.0
iOS 12
二选一,不能同时引入
Rive
RiveRuntime ~> 6.29
iOS 14
Swift 视图(RiveSwift/)遵守可播放视图协议
GIF
ImageIO
iOS 12
通过注册表播放一次;未引入时 Core 内置解码器照常播放 GIF
Subspec
Dependency
Minimum OS
Notes
CYLPlaceholderItemAnimation
none
iOS 12
Shared animator protocol, player, registry, factory and engine; pulled in only by the animation-library subspecs below; the old name Animation still works
LottieSwift (Lottie is an alias)
lottie-ios ≥ 4.5.1
iOS 13
A Swift bridge (LottieSwift/) plus an Objective-C animator; no Objective-C Lottie 2.x
PAG / PAGEnterprise
libpag / libpag-enterprise ≥ 4.0
iOS 12
Choose one; they cannot be included together
Rive
RiveRuntime ~> 6.29
iOS 14
A Swift view (RiveSwift/) conforming to the playable-view protocol
GIF
ImageIO
iOS 12
Plays once through the registry; when not included, the decoder built into Core still plays GIFs
CYLTableViewPlaceHolder.bundle/Animations/ ships 40 scenario-named animations and 22 refresh icon animations CYLRefresh* with Core (about 480 KB in total) that can be used directly as placeholders; playing Lottie, PAG and Rive needs the matching subspec, while Core plays GIF:
No internet, load failed, server error, refresh, no results, no permission, contact support, no messages, no notifications, sad, cloud off, tap hint, settings, no orders (a parcel); missing location, camera, photo, microphone, contacts, calendar, Bluetooth and notification permissions (used by the scenario placeholders)
NSString *path = [CYLPlaceholderView pathForBundledAnimation:@"CYLPlaceholderLoading.json"];
CYLPlaceholderView *loading = [[CYLPlaceholderView alloc] initWithItemAttributes:@{
CYLPlaceholderItemTitle: @"加载中",
// [CN] 动画加载前或缺少子规格时显示的图片
// [EN] The image shown before the animation loads, or when the subspec is missing
CYLPlaceholderItemStyle: @(CYLPlaceholderStyleHourglass),
CYLPlaceholderItemAnimationFilePath: path,
CYLPlaceholderItemAnimationSize: @[@180, @180],
} imageBundle:nil error:NULL];
Only animations whose content means a placeholder state are bundled (loading, progress, empty, no results, no network or a failed request, a missing permission, an action the placeholder offers, done); mascots, scenes and widget demos are not. +bundledAnimationFileNames lists all the file names. The files are all downloaded unmodified from open-source repositories: Lottie from airbnb/lottie-ios (Apache-2.0), PAG from Tencent/libpag (Apache-2.0), Rive from rive-app/rive-ios (MIT), GIF from CYLTabBarController (MIT), and the line icons from useAnimations/react-useanimations (MIT); each file's source path, commit and SHA-256 are recorded in Animations/NOTICE.animations, and the full license texts ship with the resource bundle. A placeholder animation plays only once, the way tab icons do, and there is no loop option yet; to keep one playing, call playPlaceholderAnimation on a timer (the aggregate demo does this).
Each animation library's animator lives in CYLPlaceholderAnimation/<library>/ and registers with CYLPlaceholderItemAnimatorRegistry in +load. An app can register its own animator: implement CYLPlaceholderItemAnimator, or wrap a view that conforms to CYLPlaceholderItemAnimationPlayableView with CYLPlaceholderItemViewAnimator. Core does not depend on any animation library, and these dependencies are not included by default.
The matching CYLPlaceholderItemLottieFilePath, CYLPlaceholderItemPAGFilePath, CYLPlaceholderItemRiveFilePath or the generic animation path can name a local file, and the matching size keys are supported. Lottie requires iOS 13 and Rive requires iOS 14. When loading fails, an error is logged and the static image is kept. Animation URLs and paths support the matching DarkURL/DarkFilePath of each format, and the animation reloads when switching between light and dark. For Rive, CYLPlaceholderItemAnimationOptions supports artboard, stateMachine, the data-bound active, trigger and duration (seconds, 0–60); input, triggerInput or animation select a legacy Rive state machine input, trigger or linear animation. Progress advancing has been verified for Lottie and PAG; artboard loading, the legacy boolean input and off-screen pausing have been verified for Rive; data-bound playback has not been verified.
As in CYLTabBarController, Carthage builds only the core framework; the Lottie, PAG, Rive and GIF subspecs are available only through CocoaPods. The contentMode of CYLPlaceholderItemAnimationOptions (a number or a name such as scaleAspectFit) applies to all animation libraries, and animationSpeed sets the initial playback speed (Lottie). Option values must be strings or numbers and are passed to the animator as a URL fragment. Other local animation formats can be registered through registerAnimationFactory:forFileExtension: with a UIView that implements CYLPlaceholderAnimationPlayer; factories are matched by extension and can override optional backends, but GIF uses the built-in decoder. Pass nil to unregister. Factories and their callbacks are used on the main thread; a failed resource load should be reported through errorHandler, and completion through readyHandler.
Lottie supports CYLPlaceholderItemAnimationColors, CYLPlaceholderItemAnimationDarkColors and CYLPlaceholderItemLottieDarkColors: the dictionary keys are Lottie keypaths and the values are a UIColor or a hexadecimal color string. Dark configuration overrides the normal one, and format-specific configuration takes priority. Rive supports CYLPlaceholderItemAnimationColors and CYLPlaceholderItemRiveDarkColors, with view model color property paths as keys; the color option sets the light color. A custom player can implement setAnimationColors:; PAG and GIF, like CYLTabBarController, do not support color overrides. Lottie keypath colors have been verified with a rendered-pixel test.
itemAttributes 保留传入的其他键,供将来使用;其他未实现的 TabBar 配置目前不会生效。示例 Auto → Styles 底部提供代码和 plist 两种配置演示。布局参考 CYLTabBarController;其 MIT 许可随资源包提供。
itemAttributes keeps the other keys that are passed in, for future use; other TabBar settings that are not implemented have no effect for now. The example Auto → Styles shows both the code and the plist configuration at the bottom. The layout follows CYLTabBarController; its MIT license ships with the resource bundle.
实现通过 method swizzling 拦截 UIKit 方法,影响进程中对应类的方法分发;未启用 block 的列表不安装占位视图。子类覆盖更新方法而不调用 super、以及 diffable data source 的内部更新不保证触发检查。示例应用右上角的 Auto 可体验两种列表、数据更新及取消功能。不要在同一个列表上同时依赖旧 API 与新 API;启用新 API 会移除旧占位视图。
The implementation intercepts UIKit methods with method swizzling, which affects the method dispatch of those classes in the process; lists that have not enabled the block do not install a placeholder view. Subclasses that override the update methods without calling super, and the internal updates of a diffable data source, are not guaranteed to trigger the check. Auto at the top right of the example app lets you try both kinds of list, data updates and cancellation. Do not rely on both the old and the new API on the same list; enabling the new API removes the old placeholder view.
A development version can be integrated with a CocoaPods local path or a Git branch, for example pod 'CYLTableViewPlaceHolder', :path => '../CYLTableViewPlaceHolder'. Carthage can use github "ChenYilong/CYLTableViewPlaceHolder" "<branch-or-commit>", built with carthage update --use-xcframeworks --platform iOS; link and embed CYLTableViewPlaceHolder.xcframework in the app; the resource bundle is already included in the framework.
第一步:使用 CocoaPods 导入 / Step 1: Install with CocoaPods
1.1.0 includes CYLRefresh; earlier versions do not automatically include the new features. This library supports iOS 12 and later and no longer needs a separate refresh library. Projects that used the old refresh library must migrate the old class names and category interfaces to CYLRefresh / cyl_.
A development version can also be integrated through a Git branch or a local :path. Known limitations such as paging refresh, and their verification status, are in docs/issue-progress.md.
然后使用 cocoaPods 进行安装。如果尚未安装 CocoaPods,运行以下命令进行安装:
Then install with cocoaPods. If CocoaPods is not installed yet, run this command:
gem install cocoapods
中文
English
安装成功后就可以安装依赖了。建议使用如下方式:
Once it is installed you can install the dependencies. The following is recommended:
# [CN] 禁止升级 CocoaPods 的 spec 仓库,否则会卡在 Analyzing dependencies,非常慢
# [EN] Do not update the CocoaPods spec repo, or it hangs at "Analyzing dependencies" and is very slow
pod update --verbose --no-repo-update
中文
English
如果提示找不到库,则可去掉 --no-repo-update:
If it says the library cannot be found, remove --no-repo-update:
pod update
中文
English
如果链接时报 ld: library not found for -lPods(见 #10),通常是工程与 Pods 的集成状态不一致,而不是本库的问题:
If linking reports ld: library not found for -lPods (see #10), it is usually an inconsistent integration state between the project and Pods, not a problem of this library:
1. 用 pod install 生成的 .xcworkspace 打开工程,不要直接打开 .xcodeproj。
1. Open the project through the .xcworkspace generated by pod install, not the .xcodeproj.
1. The default placeholder view fills the table view's bounds, and its width and height follow the table view. makePlaceHolderView is called again on every empty-data refresh, so you can switch between a network error view and a no-data view.
2. makePlaceHolderView 可由自定义 table view、delegate 或独立的 data source 实现,按此顺序查找;应返回非空视图。
2. makePlaceHolderView can be implemented by a custom table view, the delegate, or a separate data source, looked up in that order; it should return a non-nil view.
If the table header or the refresh footer must stay visible, implement the optional method in the object that provides the placeholder and return a region in the table view's coordinate system; call cyl_reloadData whenever the layout needs change, to update the region:
A custom frame does not follow size changes automatically; if needed, set an autoresizing mask on the returned view, or reload after layout changes. For section headers and refresh footers, compute the non-overlapping region from their actual frames in the table view's content coordinate system; with empty data the automatic footer is not necessarily at the bottom of the screen. The placeholder sits above the other subviews within its frame, but the headers, footers and trailers of CYLRefresh (and of MJRefresh, if you still use it) always stay above the placeholder, so refresh controls are not covered by a full-screen placeholder by default (#8); this holds for the old block API and cyl_reloadData alike.
This example is not a general solution for every layout: recompute it after the footer position changes; if there is also a table header or section headers, take their actual positions into account too.
With custom section headers (#16), place the placeholder starting at the bottom of the last section header; rectForHeaderInSection: already includes the table header height. The library lays out the table view before calling this callback, so the values read are the final positions (including the top spacing of plain-style section headers since iOS 15); calling cyl_reloadData again after a rotation or size change recomputes it:
Also, the placeholder view is not scrollable by default, so pull-to-refresh does not work either; to make the placeholder view scrollable, implement the optional delegate method below.
@optional
/*!
@brief enable tableView scroll when place holder view is showing,it is disabled by default.
@return YES means scrollable, NO means not scrollable
*/
- (BOOL)enableScrollWhenPlaceHolderViewShowing;
第三步:使用 cyl_reloadData 代替 reloadData / Step 3: Use cyl_reloadData instead of reloadData
中文
English
使用方法:仅需使用 cyl_reloadData 代替 reloadData 即可。
Usage: just use cyl_reloadData instead of reloadData.
Note: cyl_reloadData already calls [self.tableView reloadData]; internally, so avoid calling it again.
旧的 cyl_reloadData 与 delegate API 只管理 UITableView;UICollectionView 请使用上文的 block API(cyl_placeholderViewBlock:)。普通页面没有 data source 可供判断空状态,库不自动管理;可以直接把 CYLPlaceholderView 当作普通 UIView 加到页面上,由应用决定何时显示。需要全局统一的断网或空状态处理时,可在列表基类中统一配置 block。使用独立 data source 时,delegate 或 table view 仍可负责创建占位图,也可以让 data source 实现该协议。
The old cyl_reloadData and delegate API manage only UITableView; for UICollectionView use the block API above (cyl_placeholderViewBlock:). An ordinary page has no data source from which to judge emptiness, so the library does not manage it automatically; you can add a CYLPlaceholderView to the page like any UIView and decide when to show it. For app-wide handling of offline or empty states, configure the block once in a list base class. With a separate data source, the delegate or the table view can still create the placeholder, or the data source can implement the protocol.
The scenario CYLPlaceholderScenarioHUD and CYLPlaceholderHUD: a page's loading progress in a box over the page, with SVProgressHUD's API (show, progress, success / error / info, popActivity, delayed dismissal, styles, masks, notifications); in the loading, progress and result states the box itself is one CYLPlaceholderView (icon and text as one, no stack view); only showComponents / showScenario use a CYLPlaceholderStackView, for several components and tap actions; the loading animation reuses the refresh resources and loops by default. With the placeholder and CYLRefresh it covers a page's whole life cycle. See docs/Placeholder-HUD.md.
[CYLPlaceholderHUD showWithStatus:@"Loading…"];
// [CN] 完成后 / [EN] When done
[CYLPlaceholderHUD dismiss]; // [CN] 或 / [EN] or [CYLPlaceholderHUD showErrorWithStatus:@"Couldn't load"];
The CYLRefresh source is in CYLTableViewPlaceHolder/CYLRefresh/ and can be modified directly; no extra refresh pod is needed. After importing CYLTableViewPlaceHolder.h:
self.tableView.cyl_header = [CYLRefreshNormalHeader headerWithRefreshingBlock:^{
// [CN] 加载数据,完成后调用 endRefreshing
// [EN] Load the data, then call endRefreshing when done
}];
self.tableView.cyl_footer = [CYLRefreshAutoNormalFooter footerWithRefreshingBlock:^{
// [CN] 加载更多数据,完成后调用 endRefreshing
// [EN] Load more data, then call endRefreshing when done
}];
The original refresh library's API has been renamed: the class prefix is now CYL, and category properties and methods use cyl_. This is an API-incompatible migration: old class names, properties, category methods and custom localization keys in an app must be changed accordingly. The old unprefixed header / footer on the category are no longer provided. For manual source integration, besides all .h and .m files, add the CYLRefresh directory and its subdirectories to Header Search Paths, and copy CYLTableViewPlaceHolder.bundle, PrivacyInfo.xcprivacy and LICENSE.third-party into the app's resources. Static library integration needs -ObjC to link the categories.
This section lists every style in the order of MJRefresh's README, with MJ changed to CYL and mj_ to cyl_. Each style is one example (exampleNN) on the "Refresh" page of Examples/Example-Scenarios; each screenshot shows that example's control while refreshing, running on an iOS 27 simulator. The examples are Swift (Sources/CYLRefreshTableViewController.swift); the calls below are the same in Objective-C.
一览:下拉刷新 01–06、上拉加载 01–11、刷新图标动画(每组从上到下)。
Overview: pull-down refresh 01–06, pull-up loading 01–11, refresh icon animations (each group from top to bottom).
Auto-hide after refreshing (autoHideRefresh): since iOS 26 the navigation bar is transparent glass by default, and a retracted header sits right under it, showing through over the title. When on, the header shows only while an action is under way (pulling, refreshing, retracting after the refresh) and hides again once the refresh has ended and it is idle and fully retracted; the footer likewise shows only while pulled, loading or retracting, and hides when it is idle (or shows "no more data") and lies wholly below the bottom bars, so it no longer shows through a glass tab bar. Headers and footers have their own switch (header.autoHideRefresh, footer.autoHideRefresh), also settable on the scroll view, separately or together: cyl_autoHideRefreshHeader, cyl_autoHideRefreshFooter, cyl_autoHideRefresh (a value set before attaching applies when the control is attached); hidden, alpha and automaticallyChangeAlpha are untouched. On by default where the navigation bar is transparent by default (iOS 26 and later), unlike MJRefresh; off by default on earlier systems, where you set it to YES yourself. Below, top to bottom: the navigation bar of example01, 04 and 11 after the refresh ends.
// [CN] iOS 26 之前的系统上手动开启:刷新结束后自动隐藏刷新头
// [EN] Turn it on yourself before iOS 26: the header hides once the refresh ends
self.tableView.cyl_header.autoHideRefresh = YES;
// [CN] 刷新头、刷新尾分开或一起设置(挂上控件之前设置也会生效)
// [EN] Header and footer separately or together (also before the controls are attached)
self.tableView.cyl_autoHideRefreshHeader = YES;
self.tableView.cyl_autoHideRefreshFooter = NO;
self.tableView.cyl_autoHideRefresh = YES;
// [CN] 恢复 MJRefresh 的行为:收回后的刷新头保持可见
// [EN] MJRefresh's behavior: the retracted header stays visible
self.tableView.cyl_header.autoHideRefresh = NO;
下拉刷新 01:默认 / Pull-down refresh 01: Default
self.tableView.cyl_header = [CYLRefreshNormalHeader headerWithRefreshingBlock:^{
// [CN] 进入刷新状态后会自动调用这个 block
// [EN] Called automatically once the control enters the refreshing state
}];
// [CN] 或者:进入刷新状态后调用 target 的 action,即 [self loadNewData]
// [EN] Or: once it enters the refreshing state, call the target's action, that is [self loadNewData]
self.tableView.cyl_header = [CYLRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
// [CN] 马上进入刷新状态
// [EN] Enter the refreshing state right away
[self.tableView.cyl_header beginRefreshing];
For the usage and the general names, see "Pull-down refresh 02: animated images" below. The example's images are frames of this library's bundled refresh GIFs.
下拉刷新 03:隐藏时间 / Pull-down refresh 03: Hide the time
// [CN] 隐藏时间
// [EN] Hide the time
header.lastUpdatedTimeLabel.hidden = YES;
下拉刷新 04:隐藏状态和时间 / Pull-down refresh 04: Hide the state and time
// [CN] 隐藏时间
// [EN] Hide the time
header.lastUpdatedTimeLabel.hidden = YES;
// [CN] 隐藏状态
// [EN] Hide the state
header.stateLabel.hidden = YES;
下拉刷新 05:自定义文字 / Pull-down refresh 05: Custom text
// [CN] 设置文字
// [EN] The texts
[header setTitle:@"Pull down to refresh" forState:CYLRefreshStateIdle];
[header setTitle:@"Release to refresh" forState:CYLRefreshStatePulling];
[header setTitle:@"Loading ..." forState:CYLRefreshStateRefreshing];
// [CN] 设置字体
// [EN] The fonts
header.stateLabel.font = [UIFont systemFontOfSize:15];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14];
// [CN] 设置颜色
// [EN] The colors
header.stateLabel.textColor = [UIColor redColor];
header.lastUpdatedTimeLabel.textColor = [UIColor blueColor];
下拉刷新 06:自定义刷新控件 / Pull-down refresh 06: Custom refresh control
self.tableView.cyl_header = [CYLRefreshDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
// [CN] 实现见示例中的 CYLRefreshDIYControls.swift(CYLRefreshHeader 的子类)
// [EN] See CYLRefreshDIYControls.swift in the example (a subclass of CYLRefreshHeader)
上拉加载 01:默认 / Pull-up loading 01: Default
self.tableView.cyl_footer = [CYLRefreshAutoNormalFooter footerWithRefreshingBlock:^{
// [CN] 进入刷新状态后会自动调用这个 block
// [EN] Called automatically once the control enters the refreshing state
}];
// [CN] 或者:进入刷新状态后调用 [self loadMoreData]
// [EN] Or: call [self loadMoreData] once it enters the refreshing state
self.tableView.cyl_footer = [CYLRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
UICollectionView 02:左拉刷新 / UICollectionView 02: Pull left
self.collectionView.cyl_trailer = [CYLRefreshNormalTrailer trailerWithRefreshingBlock:^{
// [CN] 拉过最后一页后松手
// [EN] Pull past the last page and release
}];
中文
English
状态文字是箭头右侧的竖列,任何语言都完整、可读:中日韩文字放得下时与 MJRefresh 一样逐字竖排、保持正立;英文、俄文等文字(或放不下的中日韩文字)顺时针旋转 90° 从上往下读,过长时换行而不是截断(MJRefresh 一个字宽的竖列会把英文单词逐字母拆开并截断)。自定义 trailer 可调用 -cyl_placeStateLabelAtCenterX: 使用同样的排版。下图:拉过最后一页时显示完整的 “Release to see details”。
The state text is a vertical column right of the arrow, complete and readable in every language: CJK text stands upright one character per line, as in MJRefresh, when it fits; English, Russian and other text (or CJK text that does not fit) is rotated 90° clockwise to read top to bottom, and wraps instead of being cut off (MJRefresh's one-character-wide column splits English words letter by letter and cuts them off). Custom trailers get the same layout from -cyl_placeStateLabelAtCenterX:. Below: the full "Release to see details" past the last page.
MJRefresh has no such group. The animated-image controls (CYLRefreshAnimationHeader, CYLRefreshAutoAnimationFooter, CYLRefreshBackAnimationFooter: the GIF controls, not the arrow CYLRefreshNormalHeader) can show the library's bundled GIF, Lottie, PAG and Rive animations. The icon and the state text are in one CYLPlaceholderView and centered as one, so they cannot drift apart. For the usage, see "Pull-down refresh 02: animated images" below and docs/Refresh-Icon-Animation.md.
example54's Rive icon (CYLRefreshIcon.riv) turns on a transparent background: every artboard of the file had a dark grey rounded square (BG, filled #ff6f6e6e), and since 2026-11-12 the alpha of those 6 fills is 0; see "Background of the Rive refresh icon" in docs/Refresh-Icon-Animation.md. The first frame of example52's Lottie spinner is almost empty, so its icon shows only a dot in the screenshot. example55 uses MJRefresh's setImages: like every other icon, the image sequence is drawn by the icon's CYLPlaceholderView, centered as one with the state text.
The same as "The drop-down refresh 02-Animation image" of the MJRefresh documentation, with MJ changed to CYL: CYLRefreshGifHeader shows the animated images of each state with setImages:forState:. These controls also have more general names: CYLRefreshAnimationHeader, CYLRefreshBackAnimationFooter and CYLRefreshAutoAnimationFooter, with animationView, setAnimationImages:forState: and setAnimationImages:duration:forState:. The old CYLRefreshGifHeader, CYLRefreshBackGifFooter and CYLRefreshAutoGifFooter stay as their subclasses, and gifView and setImages:… call the general methods, so old code needs no change.
CYLRefreshGifHeader *header = [CYLRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
// [CN] 普通、松开即刷新、刷新中三种状态的动画图片
// [EN] The animated images of the idle, pulling and refreshing states
[header setImages:idleImages forState:CYLRefreshStateIdle];
[header setImages:pullingImages forState:CYLRefreshStatePulling];
[header setImages:refreshingImages forState:CYLRefreshStateRefreshing];
self.tableView.cyl_header = header;
// [CN] 通用名称,效果相同 / [EN] The general names, with the same result
CYLRefreshAnimationHeader *animationHeader = [CYLRefreshAnimationHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
[animationHeader setAnimationImages:refreshingImages forState:CYLRefreshStateRefreshing];
The same control can draw the library's existing GIF, Lottie, PAG and Rive animations instead of the images (CYLRefreshIconAnimating), with the same layout and show/hide timing; Lottie, PAG and Rive need their subspec (LottieSwift or Lottie, PAG, Rive), and Core plays GIF. The general names, CYLRefreshBackGifFooter and CYLRefreshAutoGifFooter work the same way. The arrow controls such as CYLRefreshNormalHeader are unchanged.
CGSize size = CGSizeMake(32, 32);
// [CN] GIF:所有状态使用同一个图标(未单独设置的状态使用空闲状态的图标)
// [EN] GIF: one icon for every state (a state without its own uses the idle icon)
[header setBundledIconAnimation:@"CYLRefreshArrows.gif" size:size forState:CYLRefreshStateIdle];
// [CN] Lottie:刷新中换成渐变加载圈
// [EN] Lottie: a gradient spinner while refreshing
[header setBundledIconAnimation:@"CYLRefreshGradientSpinner.json" size:size forState:CYLRefreshStateRefreshing];
// [CN] PAG、Rive:同样传入内置文件名,或用 setIconAnimationFilePath:size:forState: 传入任意本地文件
// [EN] PAG and Rive: pass a bundled name the same way, or any local file with setIconAnimationFilePath:size:forState:
[footer setBundledIconAnimation:@"CYLPlaceholderProgress.pag" size:size forState:CYLRefreshStateRefreshing];
[otherHeader setBundledIconAnimation:@"CYLRefreshIcon.riv" size:size forState:CYLRefreshStateIdle];
// [CN] 所有可用的内置文件 / [EN] Every bundled file you can use
NSArray<NSString *> *names = CYLRefreshAnimationHeader.bundledIconAnimationFileNames;
Swift: header.setIconAnimation(bundled: "CYLRefreshArrows.gif", size: CGSize(width: 32, height: 32), for: .idle). The "Refresh icons" page of Examples/Example-Scenarios lists every bundled file, grouped by GIF, Lottie, PAG and Rive. See docs/Refresh-Icon-Animation.md.
All localization files and images of this library are in one resource bundle, CYLTableViewPlaceHolder.bundle; there is no separate CYLRefresh.bundle any more:
Both strings tables provide seven languages, en, zh-Hans, zh-Hant, ja, ko, ru and uk, with exactly the same keys (checked one by one by the unit tests); other languages fall back to English. [NSBundle cyl_refreshBundle] is still available and returns this unified resource bundle. Refresh text can still be set to a language with languageCode of CYLRefreshConfig, or overridden in the app's own bundle with i18nBundle / i18nFilename.
Upgrading from an old version: CocoaPods and Carthage integrations need no change; manual integrations must delete CYLRefresh.bundle from the project and keep only CYLTableViewPlaceHolder.bundle. Code that reads the CYLRefresh.bundle path or the old image names [email protected] / [email protected] should use cyl_refreshBundle, cyl_arrowImage and cyl_trailArrowImage instead.
endRefreshing, endRefreshingWithNoMoreData and resetNoMoreData update the state immediately on the main thread; when called from a background thread they are still submitted to the main queue asynchronously. The automatic footer does not trigger automatically while the header is refreshing; the other combinations do not affect each other by default and can refresh independently.
To make pull-down refresh and pull-up loading mutually exclusive (upstream #1587), set exclusiveWithOtherRefresh = YES on the header, footer (or trailer) (default NO, behavior unchanged): while another component of the same scroll view is refreshing, this component does not start; the interrupted pull returns to idle, and blockedByOtherRefreshBlock is called on the main thread, which you can use to show "Refreshing, please wait". Both components must set it for a two-way exclusion; if only one sets it, only that one is blocked by the other. This is exclusion of starting a refresh; it does not change the look of the refresh controls, and there is no built-in message text.
void (^notify)(void) = ^{
// [CN] 例如 Toast:正在刷新数据
// [EN] For example, a toast: "Refreshing data"
};
header.exclusiveWithOtherRefresh = YES;
header.blockedByOtherRefreshBlock = notify;
footer.exclusiveWithOtherRefresh = YES;
footer.blockedByOtherRefreshBlock = notify;
中文
English
上拉加载到最后一页时,endRefreshingWithNoMoreData 默认让滚动视图立即回弹。给 back footer 设置 noMoreDataDisplayDuration(秒,默认 0,行为不变;上游 #1585 场景二)后,该次加载以“无更多数据”结束时,footer 保持展开并显示提示文字这么久再回弹;在此期间调用 resetNoMoreData、开始新的加载或移除 footer,会立即归还展开的底部 inset。它只作用于“刚结束一次加载”的无更多数据;进入页面时就已处于无更多数据、再上拉显示 N 秒的场景一尚未实现。
When pull-up loading reaches the last page, endRefreshingWithNoMoreData makes the scroll view rebound immediately by default. After you set noMoreDataDisplayDuration on a back footer (seconds, default 0, behavior unchanged; upstream #1585, scenario 2), a load that ends with "no more data" keeps the footer open and shows the message for that long before rebounding; calling resetNoMoreData, starting a new load, or removing the footer during that time gives the opened bottom inset back at once. It applies only to no-more-data right after a load ends; scenario 1, where the page is already in the no-more-data state on entry and a pull-up should show the message for N seconds, is not implemented yet.
CYLRefreshBackNormalFooter *footer = [CYLRefreshBackNormalFooter footerWithRefreshingBlock:^{
// [CN] 加载下一页
// [EN] Load the next page
}];
footer.noMoreDataDisplayDuration = 3;
// [CN] 加载完最后一页后:[footer endRefreshingWithNoMoreData];提示显示 3 秒后回弹
// [EN] After the last page loads: [footer endRefreshingWithNoMoreData]; the message shows for 3 seconds, then it rebounds
With paging enabled, the automatic footer no longer subtracts the whole bottom inset directly when a refresh ends: at rest it only clamps an offset beyond the normal content range back to the boundary; during dragging or deceleration it does not rewrite the offset and leaves the rebound to the scroll view.
Examples/Example-SwiftUI/ is a SwiftUI investigation project adapted from the example of the reporter of upstream #1628, and it also contains the UIViewRepresentable footer lifecycle page for #1589. Examples/Example-objc-01/ is a UIKit collection project adapted from the example of the reporter of upstream #1575; although the directory name says objc, the original example uses Swift. Run pod install in each project's directory and open the matching .xcworkspace; both use the local library through :path => '../..'. The SwiftUI example avoids installing the refresh control repeatedly by default; the launch argument -reproduce-1628 runs the original repeated configuration. The visibility of the refresh control during a real pull-down is still under investigation, so the default example must not be taken as a complete fix.
Examples/Example-objc-02/ 目前移植了 #1523 原工程的 collection 控制器,而非原工程全部页面;增加 back footer 用于检查 #1506,并支持连续下拉检查 #1483。运行 pod install 后打开该目录下的 workspace;手势完成及静止位置测试不能替代对动画闪烁或漂移的逐帧验证。
Examples/Example-objc-02/ currently ports the collection controller of the original #1523 project, not all of its pages; it adds a back footer to check #1506 and supports repeated pull-downs to check #1483. Run pod install and open the workspace in that directory; gesture-completion and resting-position tests cannot replace a frame-by-frame check of animation flicker or drift.
When switching from horizontal to vertical refresh, first set scrollView.cyl_trailer = nil, then configure the vertical footer. Removing a trailer that is refreshing first ends the refresh, takes back the right inset it added, and restores the earlier horizontal bounce setting, while keeping the inset changes the caller made afterwards. If the trailer is ended or removed before its start animation completes, that refresh callback and the begin-completion callback do not run, while the end-completion callback still does. When a trailer is reused, an old animation does not trigger a new refresh callback or reset the new pull progress; overlapping end animations call the completion callbacks they each started with.
By default a trailer refreshes only after it is pulled out and released. After you set automaticallyRefresh = YES, when the content is wider than the scroll view, scrolling toward the end until the trailer shows triggerAutomaticallyRefreshPercent of itself (default 1.0, fully visible) refreshes automatically; the properties have the same names and meanings as on the automatic footer; each drag triggers at most autoTriggerTimes automatic refreshes (default 1, -1 for unlimited), and scrolling without a drag is not limited. It does not trigger on rebound (movement toward the start) or while the header or footer is refreshing; when the content is narrower than one screen, it is still pull-and-release.
CYLRefreshNormalTrailer *trailer = [CYLRefreshNormalTrailer trailerWithRefreshingBlock:^{
// [CN] 加载更多数据,完成后调用 endRefreshing
// [EN] Load more data, then call endRefreshing when done
}];
trailer.automaticallyRefresh = YES;
collectionView.cyl_trailer = trailer;
To track the scroll direction, call [scrollView cyl_updateScrollMetrics] once to establish a baseline, then call it once in every scrollViewDidScroll:; cyl_scrollDistance and cyl_scrollDirection can be read repeatedly for the same sample. The distance is the signed number of points along the dominant axis, and the direction is the direction in which the content offset changed; for the first sample the distance is zero and the direction is CYLScrollDirectionNone.
刷新组件依据本地源码中声明的 3.7.9 版本改造,适用第三方 MIT 许可证;原版权声明、许可证及来源说明保留在源码和 CYLRefresh/LICENSE.third-party 中。
The refresh component is adapted from version 3.7.9, as declared in the local source, and the third-party MIT license applies; the original copyright notice, license and source notes are kept in the source and in CYLRefresh/LICENSE.third-party.
CYLPlaceholderStackView stacks several icon-and-title components (each one a CYLPlaceholderView) in a vertical UIStackView. The first is the reserved component, the classic icon and title; hints, buttons, separators and icons can be appended after it. Pass a CYLPlaceholderScenario value when creating it: the core's CYLPlaceholderScenarioCatalog defines the components, and the tap handlers are passed at the same time through actions.
36 scenarios (including the new HUD scenario CYLPlaceholderScenarioHUD, see docs/Placeholder-HUD.md): the 43 screenshots above are distilled into 15 scenarios (14 structures plus the missing location permission of screenshot #20; each screenshot maps to exactly one scenario, see the comment of each enum value), and 20 are common business cases (no search results, empty cart and so on), 8 of them missing permissions (location, camera, photo library, microphone, contacts, calendar, Bluetooth, notifications, plus the generic no permission). A missing permission is a category of its own (+categoryForScenario: returns Permission), kept apart from network failures: it sends the user to Settings instead of offering a retry. 34 of the 35 scenarios use a built-in animation (the text-only scenario has no icon). Every title, hint and button text lives in the core resource bundle, in seven languages.
// [CN] 携程式:图标加标题、“重试”按钮、“或”分隔符、“联系客服”按钮,两个点击事件
// [EN] Ctrip style: icon and title, a "Retry" button, an "or" separator and a "Contact support" button; two actions
let placeholder = CYLPlaceholderStackView(scenario: .retryOrContactSupport, actions: [
.retry: { [weak self] _, _ in self?.reload() },
.contactSupport: { [weak self] _, _ in
self?.navigationController?.pushViewController(SupportViewController(), animated: true)
},
])
tableView.cyl_placeholderViewBlock({ _ in placeholder })
// [CN] 什么值得买式:只有插图,下面是带背景图和圆角的可点击标题
// [EN] SMZDM style: an illustration only, then a tappable title with a background image and rounded corners
__weak typeof(self) weakSelf = self;
CYLPlaceholderStackView *placeholder = [[CYLPlaceholderStackView alloc]
initWithScenario:CYLPlaceholderScenarioIllustrationRetry
actions:@{CYLPlaceholderActionRetry: ^(CYLPlaceholderStackView *view, CYLPlaceholderAction action) {
[weakSelf reload];
}}];
Components can also be combined without a scenario: initWithComponents:actions: takes an array of CYLPlaceholderComponent (componentWithBundledAnimation:…, hintComponentWithText:, buttonComponentWithTitle:style:action:, separatorComponentWithText:, or any item attributes), and appendComponent: and setHandler:forAction: work afterwards. "Tap the screen to reload" scenarios use backgroundAction. Button looks come from new title chrome keys of CYLPlaceholderView: CYLPlaceholderItemTitleBackgroundImage, …BackgroundColor, …BorderColor, …BorderWidth, …CornerRadius, …ContentInsets and …MinimumWidth; without them the title stays plain text and the layout is unchanged.
Every component exposes its own tap API (inside CYLPlaceholderView): tapHandler, tapInteractionEnabled (off: the handler does not run and the pressed highlight does not show) and tapHighlightStyle (dim, shrink, none); CYLPlaceholderStackView sets each component's action through it when it is created. animationRepeatCount sets how many times the icon animation plays (0 loops), and scenario components loop by default. Every option can be written in a JSON or plist configuration file and loaded with initWithContentsOfURL:actions:error:.
Status bar: CYLPlaceholderStatusView is ported from CYLChatKit's LCCKStatusView ("Network unavailable, Check network") and keeps its API (initWithFrame:, delegate, statusViewClicked:, the 44-point height), drawing its icon and text with the library's icon-and-title component laid out horizontally (the new item key CYLPlaceholderItemContentAxis). The bar and the placeholder are independent: the bar goes at the top of the view controller's view, below the navigation bar; cyl_statusDisplay shows both, only the bar or only the placeholder, and cyl_showsStatusViewWhenOffline lets CYLPlaceholderNetworkMonitor (ChatKit's reachability detection, ported to NWPathMonitor) show the bar while offline; configuration files use statusBar, display and showsWhenOffline. See docs/Status-Bar.md.
Accessibility: every component is a meaningful element (its title, the button trait, the not-enabled trait when interaction is off), decorative icons are hidden from VoiceOver, separators read only their word, and components read as a group from top to bottom, with Voice Control, Switch Control, Dynamic Type and Reduce Motion supported; the rules are in instructions.md, "Accessibility". Resources are looked up per layer like strings: the core's CYLPlaceholderResourceURL(path) and each example's own lookup.
The language of core texts can change at run time: set CYLPlaceholderLocalization.language (nil follows the system); views created afterwards use the new language, and CYLPlaceholderLocalizationLanguageDidChangeNotification is posted. The core lookup macro is CYLPlaceholderLocalizedString(key, fallback); Swift calls CYLPlaceholderLocalization.localizedString(forKey:fallback:). The full scenario table and the Swift spellings are in docs/Placeholder-Scenarios.md.
Animated icons: they replace MJRefresh's animated images. CYLRefreshAnimationHeader, CYLRefreshBackAnimationFooter and CYLRefreshAutoAnimationFooter adopt CYLRefreshIconAnimating and can show a GIF, Lottie, PAG or Rive icon with the library's icon component (setBundledIconAnimation:size:forState:, setIconAnimationFilePath:size:forState:, setIconAnimationAttributes:forState:) where the animation view draws its images; setAnimationImages:forState: still shows images, the MJRefresh names such as CYLRefreshGifHeader stay as subclasses (gifView and setImages:… call the general methods) and the default arrow controls stay as they are. Pulling plays the icon or follows the pull, refreshing loops it, and ending stops it. See docs/Refresh-Icon-Animation.md.
Bundled refresh animations: the core bundle has 22 CYLRefresh* icon animations that only mean refresh states (a GIF of turning arrows and 4 GIF spinners; Lottie pull arrows, cycle/clockwise/counter-clockwise refresh arrows, spinners, dots, load-more and done checks; a Rive refresh icon), and CYLRefreshAnimationHeader.bundledIconAnimationFileNames lists them with the two placeholder animations that also mean refresh (CYLPlaceholderRefresh.json and the PAG progress ring CYLPlaceholderProgress.pag). The "Refresh icons" page (top right of the Feed tab in Examples/Example-Scenarios) has a demo page for every file and shows image sequences, an icon per state, the back footer, file path, item attributes, a configuration file and the MJRefresh Gif names. See docs/Refresh-Icon-Animation.md.
The main demo source is in Examples/Example/, written in Swift: it embeds the CYLTableViewPlaceHolderFramework target of the same project and calls import CYLTableViewPlaceHolder (no external refresh Pod): open CYLTableViewPlaceHolder.xcodeproj or the workspace at the repository root, with no need to run pod install. The published source and resources are gathered in CYLTableViewPlaceHolder/: the placeholder component is in CYLTableViewPlaceHolder/CYLTableViewPlaceHolder/ and the refresh component is in CYLTableViewPlaceHolder/CYLRefresh/, both specified by the podspec at the repository root. The Xcode 27 simulator SDK uses iOS 15 build settings, while the minimum for real devices stays iOS 12.
Examples/Example-Scenarios/ is the aggregate demo, written in Swift and calling only the library's core API: modeled on CYLTabBarController's Objective-C demo, its home screen is a CYLTabBarController with a plus button in the middle.
The fifth tab, "Refresh", transcribes the whole example layer of MJRefresh to Swift on this project's API (MJ → CYL, mj_ → cyl_): MJExampleViewController, example01–21 of MJTableViewController, UICollectionView pull down/up and pull left, WKWebView, localization, the custom controls MJDIYHeader/MJDIYAutoFooter/MJDIYBackFooter and the animated-image controls MJChiBaoZi…; the animated images use frames of the bundled refresh GIFs, and another group of pages shows GIF, Lottie, PAG and Rive icons.
Scenarios: lists all 36 scenarios of CYLPlaceholderScenarioCatalog in three groups, "README screenshots", "permission missing (not a network failure)" and "business cases"; each row shows the core's scenario name, the README screenshot numbers and the component count. Tapping a row pushes a page created with CYLPlaceholderStackView(scenario:actions:): "Retry" shows the loading scenario and then data, "Contact support" pushes a support page, "Open Settings" opens the system settings, "Choose an address manually" shows a short confirmation, and "Done" goes back; "Tap: on/off" in the navigation bar switches every component's tapInteractionEnabled. The "Configuration files" section opens 7 JSON/plist configuration files (pressed looks, interaction off, playback policies, the four animation formats and more) and can show each file. The 🌐 button at the top of the page switches the language (seven languages or the system's), and the whole interface is rebuilt in the new language, as in CYLTabBarController's Objective-C demo.
Animations: lists the 53 animation files of the core resource bundle by engine, with their sizes, and plays each one (replayed every 4 seconds); "Sources" shows NOTICE.animations. The last group is the example's own CYLScenarioExample.bundle/Animations: animations without a placeholder meaning (a mascot, a scene, widget demos) live only in the example layer and play by file path.
Flows: switching between empty / failed / offline / has data, keeping the table header and section headers, pull-down refresh and pull-up loading, a scrollable placeholder and a UICollectionView placeholder; every placeholder is a core scenario.
Feed: simulates a real list: the first load shows the loading scenario, pull-down refresh alternately fails and shows the scenario with a "Retry" button, and pull-up loading shows "No more" at the end.
加号按钮:弹出“上传中”场景(GIF),随后显示“成功”场景(动画加“完成”按钮)。
Plus button: shows the "Uploading" scenario (GIF), then the "Success" scenario (an animation and a "Done" button).
Run pod install in that directory and open Example-Scenarios.xcworkspace; it pulls in all animation subspecs through the local pod and CYLTabBarController at its newest commit (updated before each build by scripts/resolve-cyltabbarcontroller-commit.sh). Scenario texts come from the core resource bundle; the demo's own UI text (tabs, sections and so on) lives in the example's Sources/CYLScenarioExample.bundle (seven languages), and the code reads it only through the CYLScenarioLocalizedString function and the CYLScenarioL10n key enum in CYLScenarioLocalization.swift; python3 scripts/check_localizations.py checks that all resource bundles and the key enum are complete.
The four Example-* projects use the local pod; run pod install in each directory and open the workspace; their apps and Pods require iOS 15 at least, which differs from the library's iOS 12 minimum.
The Podfiles of these four Example-* projects also add the latest version of MJRefresh (this library's refresh component is adapted from it), so every build checks that the two coexist and compile. The version, the highest stable one, is read from the CocoaPods index by scripts/resolve-mjrefresh-version.sh before the build and written into each Podfile; CI's scripts/ci-build-example.sh does this automatically. The main demo at the repository root uses the refresh source through the framework target of the same project and is not affected.
android/ is this library's Android version (Kotlin): placeholder (the placeholder views) and Kotlin ports of three refresh libraries, SVPullToRefresh, android-Ultra-Pull-To-Refresh and SmartRefreshLayout (their packages, class names and licenses kept). android/merged brings them together as one library, :merged; the example :merged-example uses CYLTabBarController's Android tab bar with four tabs, one per library, and a raised plus button in the middle. Progress, issue fixes and the API table are in docs/Android-Port.md.
Build: in android/, run ./gradlew -PcylTabBarDir=<CYLTabBarController checkout>/Example-Android :merged-example:assembleDebug (without it, the CYLTabBarController/ next to this repository is used). Screenshots: Android 15 emulator (API 35), commit 2623a1c, 2026-11-14.
The first tab is a port of the iOS example's "Scenarios" page: three sections list every placeholder scenario, a row opens its page, the last group is the JSON configuration files, and the top row switches the seven languages; the fifth tab is the "Feed" page (a pull-down refresh that alternately fails and shows "Retry", pull-up loading to "No more data"), and the plus button page is "Uploading → Success" (Android 15 emulator, API 35, commit d11eb93, 2026-11-14). The progress of the other pages is in docs/Android-Port.md.
CYLTableViewPlaceHolder is based on whether the dataSource is empty, so you only need to operate on the dataSource. It triggers whenever the data source is empty. And each time the placeholder view is added with addSubview and removed with removeFromSuperview, the old one is destroyed and - (UIView *)makePlaceHolderView is triggered to create a new view. If you add an if check in that method, it fits different scenarios.
For cases where the only reason the dataSource is empty is a network failure, such as the home page, a group-buying list or a product list. For example:
携程:网络故障 / 携程: network failure
携程:网络故障 / 携程: network failure
携程:网络故障 / 携程: network failure
中文
English
代码实现时直接返回网络故障占位视图,用伪代码表示则是:
In code, simply return the network failure placeholder view; in pseudocode:
For cases where the dataSource may be empty not only because of a network failure but also because the server really has no data; here you need to check the current network before returning the placeholder view, for example:
Does ChenYilong/CYLTableViewPlaceHolder have any tags?
TopGit's last sync did not record any GitHub topics for ChenYilong/CYLTableViewPlaceHolder. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on ChenYilong/CYLTableViewPlaceHolder?
The most recent commit recorded on ChenYilong/CYLTableViewPlaceHolder was 6 days ago, based on the GitHub push timestamp. The repository has 160 forks — one of the better signals of community interest.
How many stars does ChenYilong/CYLTableViewPlaceHolder have?
ChenYilong/CYLTableViewPlaceHolder has 889 GitHub stars — refresh the page for the live number, or check github.com/ChenYilong/CYLTableViewPlaceHolder. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is ChenYilong/CYLTableViewPlaceHolder written in?
ChenYilong/CYLTableViewPlaceHolder is written primarily in Objective-C. GitHub's language field is based on the largest share of bytes in the default branch.
What license does ChenYilong/CYLTableViewPlaceHolder use?
ChenYilong/CYLTableViewPlaceHolder is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where can I see ChenYilong/CYLTableViewPlaceHolder in action?
The project maintains a homepage at http://weibo.com/luohanchenyilong. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about ChenYilong/CYLTableViewPlaceHolder?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/ChenYilong/CYLTableViewPlaceHolder is the definitive source.
Read full README in the tab above.
Want a second opinion on CYLTableViewPlaceHolder?
Ask an AI that can read this page — one click and you get its take on CYLTableViewPlaceHolder.