Skip to content

Easy to showing some empty state view for UITableView/UICollectionView

License

Notifications You must be signed in to change notification settings

sgxiang/BYStateScrollView_Swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BYStateScrollView_Swift

==============

自定义UITableView/UICollectionView为空和刷新的状态

参考 : DZNEmptyDataSet

License MIT

要求

  • iOS 7.0+
  • Xcode 7.0
  • Swift 2.0

截图

用法

设置UITableView/UICollectionView的数据代理:

class SomeTableViewController : UITableViewController , BYStateDataSource,BYStateDelegate{
	override func viewDidLoad() {
		super.viewDidLoad()
    	//...
		tableView.byStateDataSource = self
        tableView.byStateDelegate = self
    	//...
	}
}

数据源的实现:

//设置标题的文本
func byStateTitleAttributedText( scrollView : UIScrollView ) -> NSAttributedString?{
}
//设置具体内容的文本
func byStateDetailAttributedText( scrollView : UIScrollView ) -> NSAttributedString?{
}
//设置图片
func byStateImage( scrollView : UIScrollView ) -> UIImage?{
}
//设置按钮文本
func byStateButtonAttributedText( scrollView : UIScrollView , forState : UIControlState) -> NSAttributedString?{
}
//自定义配置按钮
func byStateCustomButton( scrollView : UIScrollView , button : UIButton?){
}

代理的实现:

//视图的按钮事件的实现
func byStateTapAction (scrollView : UIScrollView ){
}

设置视图的 byState (.Loading,.Custom) 来让视图显示不同的状态。

  • tableView.byState = .Loading : 设置视图在刷新状态(表单的数据必须为空)
  • tableView.byState = .Custom : 设置视图为自定义配置的状态(表单的数据必须为空)

设置完成之后调用reloadData方法去刷新视图。

Communication

Author

About

Easy to showing some empty state view for UITableView/UICollectionView

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published