All Projects → WymanLyu → Wynullview

WymanLyu / Wynullview

Licence: mit
An easy way to use for view's empty state 一行代码显示空视图,高度自定义

Projects that are alternatives of or similar to Wynullview

Statefulviewcontroller
Placeholder views based on content, loading, error or empty states
Stars: ✭ 2,139 (+4761.36%)
Mutual labels:  state, placeholder, error
react-native-easy-state-view
Fully customizable State View for React Native.
Stars: ✭ 21 (-52.27%)
Mutual labels:  state, error
PageStatusTransformer
A low invasive state management on Android
Stars: ✭ 12 (-72.73%)
Mutual labels:  state, error
Model Free Episodic Control
This is the implementation of paper Model Free Episodic Control
Stars: ✭ 31 (-29.55%)
Mutual labels:  numpy
Use Global Context
A new way to use “useContext” better
Stars: ✭ 34 (-22.73%)
Mutual labels:  state
React Shimmer
🌠 Async loading, performant Image component for React.js
Stars: ✭ 990 (+2150%)
Mutual labels:  placeholder
Unstated
State so simple, it goes without saying
Stars: ✭ 7,785 (+17593.18%)
Mutual labels:  state
Machine Learning Alpine
Alpine Container for Machine Learning
Stars: ✭ 30 (-31.82%)
Mutual labels:  numpy
Lambda Packs
Precompiled packages for AWS Lambda
Stars: ✭ 997 (+2165.91%)
Mutual labels:  numpy
Pycall.jl
Package to call Python functions from the Julia language
Stars: ✭ 985 (+2138.64%)
Mutual labels:  numpy
Make Error Cause
Make your own nested errors
Stars: ✭ 36 (-18.18%)
Mutual labels:  error
Mlcourse.ai
Open Machine Learning Course
Stars: ✭ 7,963 (+17997.73%)
Mutual labels:  numpy
Rwidgethelper
Android UI 快速开发,专治原生控件各种不服
Stars: ✭ 996 (+2163.64%)
Mutual labels:  state
Highdicom
High-level DICOM abstractions for the Python programming language
Stars: ✭ 32 (-27.27%)
Mutual labels:  numpy
Redux
redux implementation in Go/Rust
Stars: ✭ 40 (-9.09%)
Mutual labels:  state
Numpycpp
A c++ header library for matrix operation inspired Numpy Scipy, MATLAB only using Eigen.
Stars: ✭ 30 (-31.82%)
Mutual labels:  numpy
Inputaccessoryview
Input Accessory View for Commenting and Chat User Interfaces built in Swift, if you like it please "☆"
Stars: ✭ 39 (-11.36%)
Mutual labels:  placeholder
Tensorly
TensorLy: Tensor Learning in Python.
Stars: ✭ 977 (+2120.45%)
Mutual labels:  numpy
Superplaceholder.js
⚡Super charge your input placeholders
Stars: ✭ 978 (+2122.73%)
Mutual labels:  placeholder
C V2x
Analytical Models of the Performance of C-V2X Mode 4 Vehicular Communications
Stars: ✭ 38 (-13.64%)
Mutual labels:  error

WYNullView

An easy way to use when view' content is empty

Overview

How to use

  • Installation with CocoaPods:pod 'WYNullView'

  • Import the main file:#import "WYNullView.h"

  • On the empty state show default content, then all you have to do is:

if (showNullView) { // 无数据,empty data -》 show nullview
  [self.tableView wy_showNullView];
} else { // 有数据,data -》 hide nullview
  [self.tableView wy_hideNullView];
}
  • You will be able to fully customize the content and appearance of the empty states for your application
if (showNullView) { // 无数据,empty data -》 show nullview
  [self.tableView wy_showNullView:^UIView *(NullView *defaultNullView) {
     // you can do any constom operation in this block, even return a new constom UIView obj 
     // rerurn [UIView new];
     defaultNullView.desText = @"基于NullView自定义";
     defaultNullView.frame = CGRectMake(10, 10, defaultNullView.frame.size.width, defaultNullView.frame.size.height);
     defaultNullView.backgroundColor = [UIColor cyanColor];
     return defaultNullView;
  } heightOffset:0.0];
} else { // 有数据,data -》 hide nullview
  [self.tableView wy_hideNullView];
}

Implementation

  • UIView-Category add AssociatedObject "wy_nullView":
///> 空视图
@property (nonatomic, strong) UIView *wy_nullView;

  • Looking for NullView chain:

    • + (void)wy_configGlobleNullView:(NullViewHandle)nullViewHandle
    • - (void)wy_configNullView:(NullViewHandle)nullViewHandle
    • - (void)wy_showNullView:(NullViewHandle)nullViewHandle heightOffset:(CGFloat)offset
  • NullViewHandle Type:

typedef UIView *(^NullViewHandle)(NullView *defaultNullView);
  • Different methods can be used in different ways:

    • Global configuration 【View object whatever it is type, show the same content from "wy_configGlobleNullView" nullViewHandle return 】:
     [UIView wy_configGlobleNullView:^UIView *(NullView *defaultNullView) {
        // return globalNullView...
     }];
    
    • View configuration【Once config, you can call "wy_showNullView" directly, 】
     - (void)viewDidLoad {
       [mView wy_configNullView:^UIView *(NullView *defaultNullView) {
          // return nullView...
       }];
     }
     - (void)func1 {
       ...
       [mView wy_showNullView];
       ...
     }
     - (void)func2 {
       ...
       [mView wy_showNullView];
       ...
     }
    
    • If you have plenty of time, you can do the following【Equivalent to the above】:
     		
     - (void)func1 {
       ...
       [mView wy_showNullView:^UIView *(NullView *defaultNullView) {
          // return nullView...
       } heightOffset:0.0]];
       ...
     }
     - (void)func2 {
       ...
       [mView wy_showNullView:^UIView *(NullView *defaultNullView) {
         // return nullView...
        } heightOffset:0.0]];
       ...
     }
    
  • Control special subView show/hidden

    • filter obj
    
     // add objc_whitelist 
     [[mView wy_objWhitelist] addObject:makeWeakReference(mView_subView)];
    
    
    • filter class
    
     // add class_whitelist
     [[self.tableView wy_classWhitelist] addObject:makeWeakReference([mView_subView class])];
    

Hope

If you think it's useful, star to me, Free to share with ideas, issue or pull requests

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].