iOS - Swift - 图书展示项目
2016-03-06 16:28
295 查看
Swift 图书展示项目
包括Swift/AFNetworking/MJRefresh/MBProgressHUD/Toast
Demo:https://github.com/shileseal/SLBookSwift
UITableView+MJRefresh.m
在SLBook-Bridging-Header.h中写入
包括Swift/AFNetworking/MJRefresh/MBProgressHUD/Toast
Demo:https://github.com/shileseal/SLBookSwift
1.block里面要用self.防止循环使用
2.cocoa pods的写法,use_frameworks!是使用动态库,直接import oc库,如果没有这句话会默认使用静态库,只能使用桥接
platform :ios, ‘8.0’ use_frameworks! pod 'AFNetworking', '~> 3.0.4' pod 'MBProgressHUD', '~> 0.9.2' pod 'Toast', '~> 3.0' pod 'SDWebImage', '~> 3.7.5' pod 'MJRefresh', '~> 3.1.0'
3.为数组建立索引
for (i,dict) in array.enumerate() { self.books.append(Book(dict: dict)) indexPaths.append(NSIndexPath(forRow: count + i, inSection: 0)) }
4.oc中返回值为instancetype,在swift中无法直接使用
+ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 要使用MJRefresh,重写以下方法 //添加顶部刷新 - (void)headerAddMJRefresh:(MJRefreshComponentRefreshingBlock)block; //手动顶部刷新 - (void)headerBeginRefresh; //取消顶部刷新状态 - (void)headerEndRefresh; //添加底部刷新 - (void)footerAddMJRefresh:(MJRefreshComponentRefreshingBlock)block; //手动刷新底部 - (void)footerBeginRefresh; //取消底部刷新状态 - (void)footerEndRefresh; //取消底部刷新状态并显示无更多数据 - (void)footerEndRefreshNoMoreData; //重置无数据状态 - (void)footerResetNoMoreData;
5.添加oc文件的时候,会添加桥接文件,需要在桥接文件中添加对oc头文件的引用
UITableView+MJRefresh.hUITableView+MJRefresh.m
在SLBook-Bridging-Header.h中写入
#import "UITableView+MJRefresh.h"
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- Apple Swift学习教程
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 介绍 Fedora 上的 Swift
- javascript demo 基本技巧
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用中UISearchDisplayController搜索效果的用法
- IOS开发环境windows化攻略
- 浅析iOS应用开发中线程间的通信与线程安全问题
- Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍
- Swift编程中的泛型解析
- Swift中定义二维数组的方法及遍历方法示例