内容简介:Swift iOS : 上拉刷新或者下拉刷新
框架MJRefresh提供了上拉刷新或者下拉刷新,非常的喜闻乐见。
需要使用pod:
target 'Swift-MJrefresh' do use_frameworks! # Pods for Swift-MJrefresh pod 'MJRefresh' end
记得去执行命令安装此框架:
pod install --verbose --no-repo-update
如下案例,演示此框架的使用过程:
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window : UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { window = UIWindow() window!.rootViewController = Page() window!.rootViewController!.view.backgroundColor = .blue window!.makeKeyAndVisible() return true } } import MJRefresh class Page: UIViewController ,UITableViewDataSource{ var tableview: UITableView! let header = MJRefreshNormalHeader() let footer = MJRefreshAutoNormalFooter() override func viewDidLoad() { super.viewDidLoad() self.tableview = UITableView() tableview.dataSource = self tableview.frame = view.frame self.view.addSubview(tableview) header.setRefreshingTarget(self, refreshingAction: Selector("headerRefresh")) self.tableview.mj_header = header footer.setRefreshingTarget(self, refreshingAction: Selector("footerRefresh")) self.tableview.mj_footer = footer } func headerRefresh(){ print("下拉刷新") self.tableview.mj_header.endRefreshing() } var index = 0 func footerRefresh(){ print("上拉刷新") self.tableview.mj_footer.endRefreshing() // 2次后模拟没有更多数据 index = index + 1 if index > 2 { footer.endRefreshingWithNoMoreData() } } func numberOfSections(in: UITableView) -> Int { return 1; } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 10; } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "a") cell.textLabel!.text = "测试刷新" return cell } func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: IndexPath) -> CGFloat { return 150; } }
实验发现,即使是Obj-c写的框架,也只要:
import MJRefresh
而不再需要桥接文件(bridge.h)。以前都是需要的,为什么不需要了?还需要进一步查明。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Swift iOS : 上拉刷新或者下拉刷新
- 上拉加载 下拉刷新
- 炫酷的列表下拉刷新效果
- Android中ListView下拉刷新的实现
- iOS 下拉刷新组件原理及简单实现
- CBPullToReflesh:下拉刷新也可以很美(Swift)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Algorithmic Beauty of Plants
Przemyslaw Prusinkiewicz、Aristid Lindenmayer / Springer / 1996-4-18 / USD 99.00
Now available in an affordable softcover edition, this classic in Springer's acclaimed Virtual Laboratory series is the first comprehensive account of the computer simulation of plant development. 150......一起来看看 《The Algorithmic Beauty of Plants》 这本书的介绍吧!