*************application

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  2. {
  3. // 1.创建窗口
  4. self.window = [[UIWindow alloc] init];
  5. self.window.frame = [UIScreen mainScreen].bounds;
  6.  
  7. // 2.设置根控制器
  8. HWAccount *account = [HWAccountTool account];
  9. if (account) { // 之前已经登录成功过
  10. [self.window switchRootViewController];
  11. } else {
  12. self.window.rootViewController = [[HWOAuthViewController alloc] init]; //授权登陆的界面
  13. }
  14.  
  15. // 3.显示窗口
  16. [self.window makeKeyAndVisible];
  17. return YES;
  18. }

*************存储账号的信息HWAccountTool.m

  1. // 账号的存储路径
  2. #define HWAccountPath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.archive"]
  3.  
  4. #import "HWAccountTool.h"
  5. #import "HWAccount.h"
  6.  
  7. @implementation HWAccountTool
  8.  
  9. /**
  10. * 存储账号信息
  11. *
  12. * @param account 账号模型
  13. */
  14. + (void)saveAccount:(HWAccount *)account
  15. {
  16. // 获得账号存储的时间(accessToken的产生时间)
  17. account.created_time = [NSDate date];
  18.  
  19. // 自定义对象的存储必须用NSKeyedArchiver,不再有什么writeToFile方法
  20. [NSKeyedArchiver archiveRootObject:account toFile:HWAccountPath];
  21. }
  22.  
  23. /**
  24. * 返回账号信息
  25. *
  26. * @return 账号模型(如果账号过期,返回nil)
  27. */
  28. + (HWAccount *)account
  29. {
  30. // 加载模型
  31. HWAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:HWAccountPath];
  32.  
  33. /* 验证账号是否过期 */
  34.  
  35. // 过期的秒数
  36. long long expires_in = [account.expires_in longLongValue];
  37. // 获得过期时间
  38. NSDate *expiresTime = [account.created_time dateByAddingTimeInterval:expires_in];
  39. // 获得当前时间
  40. NSDate *now = [NSDate date];
  41.  
  42. // 如果expiresTime <= now,过期
  43. /**
  44. NSOrderedAscending = -1L, 升序,右边 > 左边
  45. NSOrderedSame, 一样
  46. NSOrderedDescending 降序,右边 < 左边
  47. */
  48. NSComparisonResult result = [expiresTime compare:now];
  49. if (result != NSOrderedDescending) { // 过期
  50. return nil;
  51. }
  52.  
  53. return account;
  54. }
  55. @end

*******HWAccount.m

  1. #import "HWAccount.h"
  2.  
  3. @implementation HWAccount
  4. + (instancetype)accountWithDict:(NSDictionary *)dict
  5. {
  6. HWAccount *account = [[self alloc] init];
  7. account.access_token = dict[@"access_token"];
  8. account.uid = dict[@"uid"];
  9. account.expires_in = dict[@"expires_in"];
  10. return account;
  11. }
  12.  
  13. /**
  14. * 当一个对象要归档进沙盒中时,就会调用这个方法
  15. * 目的:在这个方法中说明这个对象的哪些属性要存进沙盒
  16. */
  17. - (void)encodeWithCoder:(NSCoder *)encoder
  18. {
  19. [encoder encodeObject:self.access_token forKey:@"access_token"];
  20. [encoder encodeObject:self.expires_in forKey:@"expires_in"];
  21. [encoder encodeObject:self.uid forKey:@"uid"];
  22. [encoder encodeObject:self.created_time forKey:@"created_time"];
  23. }
  24.  
  25. /**
  26. * 当从沙盒中解档一个对象时(从沙盒中加载一个对象时),就会调用这个方法
  27. * 目的:在这个方法中说明沙盒中的属性该怎么解析(需要取出哪些属性)
  28. */
  29. - (id)initWithCoder:(NSCoder *)decoder
  30. {
  31. if (self = [super init]) {
  32. self.access_token = [decoder decodeObjectForKey:@"access_token"];
  33. self.expires_in = [decoder decodeObjectForKey:@"expires_in"];
  34. self.uid = [decoder decodeObjectForKey:@"uid"];
  35. self.created_time = [decoder decodeObjectForKey:@"created_time"];
  36. }
  37. return self;
  38. }
  39. @end

*********HWAccount.h

  1. #import <Foundation/Foundation.h>
  2.  
  3. @interface HWAccount : NSObject <NSCoding>
  4. /** string 用于调用access_token,接口获取授权后的access token。*/
  5. @property (nonatomic, copy) NSString *access_token;
  6.  
  7. /** string access_token的生命周期,单位是秒数。*/
  8. @property (nonatomic, copy) NSNumber *expires_in;
  9.  
  10. /** string 当前授权用户的UID。*/
  11. @property (nonatomic, copy) NSString *uid;
  12.  
  13. /** access token的创建时间 */
  14. @property (nonatomic, strong) NSDate *created_time;
  15.  
  16. + (instancetype)accountWithDict:(NSDictionary *)dict;
  17. @end

**********HWOAuthViewController.m

  1. #import "HWOAuthViewController.h"
  2. #import "AFNetworking.h"
  3. #import "HWAccount.h"
  4. #import "HWAccountTool.h"
  5. #import "MBProgressHUD+MJ.h"
  6.  
  7. @interface HWOAuthViewController () <UIWebViewDelegate>
  8.  
  9. @end
  10.  
  11. @implementation HWOAuthViewController
  12.  
  13. - (void)viewDidLoad
  14. {
  15. [super viewDidLoad];
  16.  
  17. // 1.创建一个webView
  18. UIWebView *webView = [[UIWebView alloc] init];
  19. webView.frame = self.view.bounds;
  20. webView.delegate = self;
  21. [self.view addSubview:webView];
  22.  
  23. // 2.用webView加载登录页面(新浪提供的)
  24. // 请求地址:https://api.weibo.com/oauth2/authorize
  25. /* 请求参数:
  26. client_id true string 申请应用时分配的AppKey。
  27. redirect_uri true string 授权回调地址,站外应用需与设置的回调地址一致,站内应用需填写canvas page的地址。
  28. */
  29. NSURL *url = [NSURL URLWithString:@"https://api.weibo.com/oauth2/authorize?client_id=3235932662&redirect_uri=http://www.baidu.com"];
  30. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  31. [webView loadRequest:request];
  32. }
  33.  
  34. #pragma mark - webView代理方法
  35. - (void)webViewDidFinishLoad:(UIWebView *)webView
  36. {
  37. [MBProgressHUD hideHUD];
  38. }
  39.  
  40. - (void)webViewDidStartLoad:(UIWebView *)webView
  41. {
  42. [MBProgressHUD showMessage:@"正在加载..."];
  43. }
  44.  
  45. - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
  46. {
  47. [MBProgressHUD hideHUD];
  48. }
  49.  
  50. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  51. {
  52. // 1.获得url
  53. NSString *url = request.URL.absoluteString;
  54.  
  55. // 2.判断是否为回调地址
  56. NSRange range = [url rangeOfString:@"code="];
  57. if (range.length != ) { // 是回调地址
  58. // 截取code=后面的参数值
  59. int fromIndex = range.location + range.length;
  60. NSString *code = [url substringFromIndex:fromIndex];
  61.  
  62. // 利用code换取一个accessToken
  63. [self accessTokenWithCode:code];
  64.  
  65. // 禁止加载回调地址
  66. return NO;
  67. }
  68.  
  69. return YES;
  70. }
  71.  
  72. /**
  73. * 利用code(授权成功后的request token)换取一个accessToken
  74. *
  75. * @param code 授权成功后的request token
  76. */
  77. - (void)accessTokenWithCode:(NSString *)code
  78. {
  79. /*
  80. URL:https://api.weibo.com/oauth2/access_token
  81.  
  82. 请求参数:
  83. client_id:申请应用时分配的AppKey
  84. client_secret:申请应用时分配的AppSecret
  85. grant_type:使用authorization_code
  86. redirect_uri:授权成功后的回调地址
  87. code:授权成功后返回的code
  88. */
  89. // 1.请求管理者
  90. AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
  91. // mgr.responseSerializer = [AFJSONResponseSerializer serializer];
  92. // AFN的AFJSONResponseSerializer默认不接受text/plain这种类型
  93.  
  94. // 2.拼接请求参数
  95. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  96. params[@"client_id"] = @"";
  97. params[@"client_secret"] = @"227141af66d895d0dd8baca62f73b700";
  98. params[@"grant_type"] = @"authorization_code";
  99. params[@"redirect_uri"] = @"http://www.baidu.com";
  100. params[@"code"] = code;
  101.  
  102. // 3.发送请求
  103. [mgr POST:@"https://api.weibo.com/oauth2/access_token" parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
  104. [MBProgressHUD hideHUD];
  105.  
  106. // 将返回的账号字典数据 --> 模型,存进沙盒
  107. HWAccount *account = [HWAccount accountWithDict:responseObject];
  108. // 存储账号信息
  109. [HWAccountTool saveAccount:account];
  110.  
  111. // 切换窗口的根控制器
  112. UIWindow *window = [UIApplication sharedApplication].keyWindow;
  113. [window switchRootViewController];
  114.  
  115. // UIWindow的分类、HWWindowTool
  116. // UIViewController的分类、HWControllerTool
  117. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  118. [MBProgressHUD hideHUD];
  119. HWLog(@"请求失败-%@", error);
  120. }];
  121. }
  122. @end

UIWindow+Extension.m

  1. #import "UIWindow+Extension.h"
  2. #import "HWTabBarViewController.h"
  3. #import "HWNewfeatureViewController.h"
  4.  
  5. @implementation UIWindow (Extension)
  6. - (void)switchRootViewController
  7. {
  8. NSString *key = @"CFBundleVersion";
  9. // 上一次的使用版本(存储在沙盒中的版本号)
  10. NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
  11. // 当前软件的版本号(从Info.plist中获得)
  12. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
  13.  
  14. if ([currentVersion isEqualToString:lastVersion]) { // 版本号相同:这次打开和上次打开的是同一个版本
  15. self.rootViewController = [[HWTabBarViewController alloc] init];
  16. } else { // 这次打开的版本和上一次不一样,显示新特性
  17. self.rootViewController = [[HWNewfeatureViewController alloc] init];
  18.  
  19. // 将当前的版本号存进沙盒
  20. [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
  21. [[NSUserDefaults standardUserDefaults] synchronize];
  22. }
  23. }
  24. @end

************HWHomeViewController.m

  1. #import "HWHomeViewController.h"
  2. #import "HWDropdownMenu.h"
  3. #import "HWTitleMenuViewController.h"
  4. #import "AFNetworking.h"
  5. #import "HWAccountTool.h"
  6. #import "HWTitleButton.h"
  7. #import "UIImageView+WebCache.h"
  8. #import "HWUser.h"
  9. #import "HWStatus.h"
  10. #import "MJExtension.h" // 第三方的框架
  11.  
  12. @interface HWHomeViewController () <HWDropdownMenuDelegate>
  13. /**
  14. * 微博数组(里面放的都是HWStatus模型,一个HWStatus对象就代表一条微博)
  15. */
  16. @property (nonatomic, strong) NSMutableArray *statuses;
  17. @end
  18.  
  19. @implementation HWHomeViewController
  20.  
  21. - (NSMutableArray *)statuses
  22. {
  23. if (!_statuses) {
  24. self.statuses = [NSMutableArray array];
  25. }
  26. return _statuses;
  27. }
  28.  
  29. - (void)viewDidLoad
  30. {
  31. [super viewDidLoad];
  32.  
  33. // 设置导航栏内容
  34. [self setupNav];
  35.  
  36. // 获得用户信息(昵称)
  37. [self setupUserInfo];
  38.  
  39. // 集成刷新控件
  40. [self setupRefresh];
  41. }
  42.  
  43. /**
  44. * 3. 集成刷新控件
  45. */
  46. - (void)setupRefresh
  47. {
  48. UIRefreshControl *control = [[UIRefreshControl alloc] init];
  49. [control addTarget:self action:@selector(refreshStateChange:) forControlEvents:UIControlEventValueChanged];
  50. [self.tableView addSubview:control];
  51. }
  52.  
  53. /**
  54. * 3-1 UIRefreshControl进入刷新状态:加载最新的数据
  55. */
  56. - (void)refreshStateChange:(UIRefreshControl *)control
  57. {
  58. // 1.请求管理者
  59. AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
  60.  
  61. // 2.拼接请求参数
  62. HWAccount *account = [HWAccountTool account];
  63. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  64. params[@"access_token"] = account.access_token;
  65.  
  66. // 取出最前面的微博(最新的微博,ID最大的微博)
  67. HWStatus *firstStatus = [self.statuses firstObject];
  68. if (firstStatus) {
  69. // 若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0
  70. params[@"since_id"] = firstStatus.idstr;
  71. }
  72.  
  73. // 3.发送请求
  74. [mgr GET:@"https://api.weibo.com/2/statuses/friends_timeline.json" parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
  75. // 将 "微博字典"数组 转为 "微博模型"数组
  76. NSArray *newStatuses = [HWStatus objectArrayWithKeyValuesArray:responseObject[@"statuses"]]; //第三方的框架
  77.  
  78. // 将最新的微博数据,添加到总数组的最前面
  79. NSRange range = NSMakeRange(, newStatuses.count);
  80. NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:range];
  81. [self.statuses insertObjects:newStatuses atIndexes:set];
  82.  
  83. // 刷新表格
  84. [self.tableView reloadData];
  85.  
  86. // 结束刷新刷新
  87. [control endRefreshing];
  88. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  89. HWLog(@"请求失败-%@", error);
  90.  
  91. // 结束刷新刷新
  92. [control endRefreshing];
  93. }];
  94. }
  95.  
  96. /**
  97. * 2. 获得用户信息(昵称)
  98. */
  99. - (void)setupUserInfo
  100. {
  101. // 1.请求管理者
  102. AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
  103.  
  104. // 2.拼接请求参数
  105. HWAccount *account = [HWAccountTool account];
  106. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  107. params[@"access_token"] = account.access_token;
  108. params[@"uid"] = account.uid;
  109.  
  110. // 3.发送请求
  111. [mgr GET:@"https://api.weibo.com/2/users/show.json" parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
  112. // 标题按钮
  113. UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
  114. // 设置名字
  115. HWUser *user = [HWUser objectWithKeyValues:responseObject];
  116. [titleButton setTitle:user.name forState:UIControlStateNormal];
  117.  
  118. // 存储昵称到沙盒中
  119. account.name = user.name;
  120. [HWAccountTool saveAccount:account];
  121. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  122. HWLog(@"请求失败-%@", error);
  123. }];
  124. }
  125.  
  126. /**
  127. * 1. 设置导航栏内容
  128. */
  129. - (void)setupNav
  130. {
  131. /* 设置导航栏上面的内容 */
  132. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(friendSearch) image:@"navigationbar_friendsearch" highImage:@"navigationbar_friendsearch_highlighted"];
  133. self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(pop) image:@"navigationbar_pop" highImage:@"navigationbar_pop_highlighted"];
  134.  
  135. /* 中间的标题按钮 */
  136. HWTitleButton *titleButton = [[HWTitleButton alloc] init];
  137. // 设置图片和文字
  138. NSString *name = [HWAccountTool account].name;
  139. [titleButton setTitle:name?name:@"首页" forState:UIControlStateNormal];
  140. // 监听标题点击
  141. [titleButton addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
  142. self.navigationItem.titleView = titleButton;
  143. }
  144.  
  145. /**
  146. * 1-1 标题点击
  147. */
  148. - (void)titleClick:(UIButton *)titleButton
  149. {
  150. // 1.创建下拉菜单
  151. HWDropdownMenu *menu = [HWDropdownMenu menu];
  152. menu.delegate = self;
  153.  
  154. // 2.设置内容
  155. HWTitleMenuViewController *vc = [[HWTitleMenuViewController alloc] init];
  156. vc.view.height = ;
  157. vc.view.width = ;
  158. menu.contentController = vc;
  159.  
  160. // 3.显示
  161. [menu showFrom:titleButton];
  162. }
  163.  
  164. - (void)friendSearch
  165. {
  166. NSLog(@"friendSearch");
  167. }
  168.  
  169. - (void)pop
  170. {
  171. NSLog(@"pop");
  172. }
  173.  
  174. #pragma mark - HWDropdownMenuDelegate
  175. /**
  176. * 下拉菜单被销毁了
  177. */
  178. - (void)dropdownMenuDidDismiss:(HWDropdownMenu *)menu
  179. {
  180. UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
  181. // 让箭头向下
  182. titleButton.selected = NO;
  183. }
  184.  
  185. /**
  186. * 下拉菜单显示了
  187. */
  188. - (void)dropdownMenuDidShow:(HWDropdownMenu *)menu
  189. {
  190. UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
  191. // 让箭头向上
  192. titleButton.selected = YES;
  193. }
  194.  
  195. #pragma mark - Table view data source
  196. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  197. {
  198. return self.statuses.count;
  199. }
  200.  
  201. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  202. {
  203. static NSString *ID = @"status";
  204. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  205. if (!cell) {
  206. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  207. }
  208.  
  209. // 取出这行对应的微博字典
  210. HWStatus *status = self.statuses[indexPath.row];
  211.  
  212. // 取出这条微博的作者(用户)
  213. HWUser *user = status.user;
  214. cell.textLabel.text = user.name;
  215.  
  216. // 设置微博的文字
  217. cell.detailTextLabel.text = status.text;
  218.  
  219. // 设置头像
  220. UIImage *placehoder = [UIImage imageNamed:@"avatar_default_small"];
  221. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:placehoder];
  222.  
  223. return cell;
  224. }
  225.  
  226. /**
  227. 1.将字典转为模型
  228. 2.能够下拉刷新最新的微博数据
  229. 3.能够上拉加载更多的微博数据
  230. */
  231. @end

***HWTitleButton.h

  1. #import "HWTitleButton.h"
  2.  
  3. @implementation HWTitleButton
  4.  
  5. - (id)initWithFrame:(CGRect)frame
  6. {
  7. self = [super initWithFrame:frame];
  8. if (self) {
  9. [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  10. self.titleLabel.font = [UIFont boldSystemFontOfSize:];
  11. [self setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
  12. [self setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
  13. }
  14. return self;
  15. }
  16.  
  17. - (void)layoutSubviews
  18. {
  19. [super layoutSubviews];
  20. // 如果仅仅是调整按钮内部titleLabel和imageView的位置,那么在layoutSubviews中单独设置位置即可
  21.  
  22. // 1.计算titleLabel的frame
  23. self.titleLabel.x = self.imageView.x;
  24.  
  25. // 2.计算imageView的frame
  26. self.imageView.x = CGRectGetMaxX(self.titleLabel.frame);
  27. }
  28.  
  29. - (void)setTitle:(NSString *)title forState:(UIControlState)state
  30. {
  31. [super setTitle:title forState:state];
  32.  
  33. // 只要修改了文字,就让按钮重新计算自己的尺寸
  34. [self sizeToFit];
  35. }
  36.  
  37. - (void)setImage:(UIImage *)image forState:(UIControlState)state
  38. {
  39. [super setImage:image forState:state];
  40.  
  41. // 只要修改了图片,就让按钮重新计算自己的尺寸
  42. [self sizeToFit];
  43. }
  44. @end
  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface HWTitleButton : UIButton
  4.  
  5. @end

HWStatus.h

  1. #import <Foundation/Foundation.h>
  2. @class HWUser;
  3.  
  4. @interface HWStatus : NSObject
  5. /** string 字符串型的微博ID*/
  6. @property (nonatomic, copy) NSString *idstr;
  7.  
  8. /** string 微博信息内容*/
  9. @property (nonatomic, copy) NSString *text;
  10.  
  11. /** object 微博作者的用户信息字段 详细*/
  12. @property (nonatomic, strong) HWUser *user;
  13. @end

HWStatus.m

  1. #import "HWStatus.h"
  2.  
  3. @implementation HWStatus
  4. @end

IOS第四天-新浪微博 -存储优化OAuth授权账号信息,下拉刷新,字典转模型的更多相关文章

  1. iOS开源项目推荐|下拉刷新

    MJRefresh - 仅需一行代码就可以为UITableView或者CollectionView加上下拉刷新或者上拉刷新功能.可以自定义上下拉刷新的文字说明. CBStoreHouseRefresh ...

  2. IOS学习笔记34—EGOTableViewPullRefresh实现下拉刷新

    移动应用开发中有这么一种场景,就是在列表中显示的数据刷新,有点击刷新按钮刷新的,也有现在最流行的由Twitter首先推出的下拉刷新功能,在IOS中,使用下拉刷新更新UITableView中的数据也用的 ...

  3. iOS下拉刷新和上拉刷新

    在iOS开发中,我们经常要用到下拉刷新和上拉刷新来加载新的数据,当前这也适合分页.iOS原生就带有该方法,下面就iOS自带的下拉刷新方法来简单操作. 上拉刷新 1.在TableView里,一打开软件, ...

  4. 高仿IOS下拉刷新的粘虫效果

    最近看需要做一款下拉刷新的效果,由于需要和Ios界面保持一致,所以这用安卓的方式实现了ios下的下拉刷新的粘虫效果. 最新的安卓手机版本的QQ也有这种类似的效果,就是拖动未读信息的那个红色圆圈,拖动近 ...

  5. IOS tableview下拉刷新上拉加载分页

    http://code4app.com/ios/快速集成下拉上拉刷新/52326ce26803fabc46000000 刷新没用用插件,加载使用的MJ老师的插件. - (void)viewDidLoa ...

  6. IOS 开发下拉刷新和上拉加载更多

    IOS 开发下拉刷新和上拉加载更多 简介 1.常用的下拉刷新的实现方式 (1)UIRefreshControl (2)EGOTTableViewrefresh (3)AH3DPullRefresh ( ...

  7. IOS UITableView下拉刷新和上拉加载功能的实现

    在IOS开发中UITableView是非常常用的一个功能,而在使用UITableView的时候我们经常要用到下拉刷新和上拉加载的功能,今天花时间实现了简单的UITableView的下拉刷新和上拉加载功 ...

  8. 简单的下拉刷新以及优化--SwipeRefreshLayout

    代码工程简要说明:以一个SwipeRefreshLayout包裹ListView,SwipeRefreshLayout接管ListView的下拉事件,若ListView被用户触发下拉动作后,Swipe ...

  9. iOS开发 XML解析和下拉刷新,上拉加载更多

    iOS开发 XML解析和下拉刷新,上拉加载更多 1.XML格式 <?xml version="1.0" encoding="utf-8" ?> 表示 ...

随机推荐

  1. 如何清除Xcode8打印的系统日志

    Xcode升级成8之后,就会发现控制台打印的日志莫名其妙的变得超级多,最关键的是很多都是没有用的东西,而有些有用的东西却淹没在那无任何卵用的里面,在这我就说一下如何关掉这些没有用的日志. 1.直接快捷 ...

  2. 从匿名方法到 Lambda 表达式的推演过程

    Lambda 表达式是一种可用于创建委托或表达式目录树类型的匿名函数. 通过使用 lambda 表达式,可以写入可作为参数传递或作为函数调用值返回的本地函数. 以上是msdn官网对Lambda 表达式 ...

  3. 软件架构---nop插件学习

    http://www.cnblogs.com/haoxinyue/archive/2013/06/06/3105541.html http://www.cnblogs.com/aaa6818162/p ...

  4. oracle去除重复字段

    ) 代码摘自百度.

  5. day4

    第八单元 1)使用cat命令进行文件的纵向合并 文件的写入 2)wc -l显示有多少行 3)管道符 "|"将上一个命令交给下一个命令的参数 4)归档tar c:创建一个新的tar文 ...

  6. 通过FileHandle获取FileObject对象

    <div id="wrap"> <!-- google_ad_section_start --> NTSTATUS MyNtReadFile(<br& ...

  7. linux python更新

    linux的yum依赖自带的Python,为了防止错误,此处更新其实是再安装一个Python 1.查看默认python版本 python -v 2.安装gcc,用于编辑Python源码 yum ins ...

  8. DFS序+线段树+bitset CF 620E New Year Tree(圣诞树)

    题目链接 题意: 一棵以1为根的树,树上每个节点有颜色标记(<=60),有两种操作: 1. 可以把某个节点的子树的节点(包括本身)都改成某种颜色 2. 查询某个节点的子树上(包括本身)有多少个不 ...

  9. HDU5909 Tree Cutting(树形DP + FWT)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5909 Description Byteasar has a tree T with n ve ...

  10. Set和存储顺序

    set(interface) 存入Set的每个元素必须是唯一的,因为Set不保存重复的元素.加入Set的元素必须定义 equal()方法以确保对象的唯一性.Set和Collection有完全一样的接口 ...