1.主控制器:
  1. 1 //
  2. 2 // ViewController.m
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import "ViewController.h"
  10. 10 #import "GroupPurchase.h"
  11. 11 #import "GroupPurchaseCell.h"
  12. 12 #import "FooterRefreshView.h"
  13. 13 #import "HeaderAdView.h"
  14. 14
  15. 15
  16. 16 @interface ViewController () <FooterRefreshViewDelegate>
  17. 17
  18. 18 @property(nonatomic, strong) NSArray *groupPurchases;
  19. 19
  20. 20 @end
  21. 21
  22. 22 @implementation ViewController
  23. 23
  24. 24 - (void)viewDidLoad {
  25. 25 [super viewDidLoad];
  26. 26 // Do any additional setup after loading the view, typically from a nib.
  27. 27
  28. 28 // 创建尾部控件
  29. 29 FooterRefreshView *footerView = [FooterRefreshView footerRrefreshViewWithDelegate:self];
  30. 30
  31. 31 // 设置尾部控件
  32. 32 self.tableView.tableFooterView = footerView;
  33. 33
  34. 34
  35. 35 //设置头部广告
  36. 36 HeaderAdView *adView = [self genAdView]; // 手动拼装广告图片数据
  37. 37 self.tableView.tableHeaderView = adView;
  38. 38 }
  39. 39
  40. 40 - (void)didReceiveMemoryWarning {
  41. 41 [super didReceiveMemoryWarning];
  42. 42 // Dispose of any resources that can be recreated.
  43. 43 }
  44. 44
  45. 45 #pragma mark - 状态栏
  46. 46 - (BOOL)prefersStatusBarHidden {
  47. 47 return YES;
  48. 48 }
  49. 49
  50. 50
  51. 51 #pragma mark - 数据方法
  52. 52 /** 延迟数据加载到model */
  53. 53 - (NSArray *) groupPurchases {
  54. 54 if (nil == _groupPurchases) {
  55. 55 NSArray *dictArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tgs.plist" ofType:nil]];
  56. 56
  57. 57 NSMutableArray *mdictArray = [NSMutableArray array];
  58. 58 for (NSDictionary *dict in dictArray) {
  59. 59 GroupPurchase *groupPurchase = [GroupPurchase groupPurchaseWithDictionary:dict];
  60. 60 [mdictArray addObject:groupPurchase];
  61. 61 }
  62. 62
  63. 63 _groupPurchases = mdictArray;
  64. 64 }
  65. 65
  66. 66 return _groupPurchases;
  67. 67 }
  68. 68
  69. 69 /** section数 */
  70. 70 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  71. 71 return 1;
  72. 72 }
  73. 73
  74. 74 /** 行数 */
  75. 75 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  76. 76 return self.groupPurchases.count;
  77. 77 }
  78. 78
  79. 79 /** 内容 */
  80. 80 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  81. 81
  82. 82 // 1.创建cell
  83. 83 GroupPurchaseCell *cell = [GroupPurchaseCell groupPurchaseCellWithTableView:self.tableView];
  84. 84
  85. 85 // 2.给cell传递model数据
  86. 86 cell.groupPurchase = self.groupPurchases[indexPath.row];
  87. 87
  88. 88 return cell;
  89. 89 }
  90. 90
  91. 91 /** 行高 */
  92. 92 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  93. 93 return 80;
  94. 94 }
  95. 95
  96. 96 /** 实现FooterRefreshViewDelegate协议 */
  97. 97 - (void)footerRefreshViewClickedFooterRefreshButton:(FooterRefreshView *)footerRefreshView {
  98. 98 //增加团购记录
  99. 99 GroupPurchase *groupPurchase = [GroupPurchase groupPurchase];
  100. 100 groupPurchase.icon = @"M2Mini.jpg";
  101. 101 groupPurchase.title = @"增加用例";
  102. 102 groupPurchase.price = @"88";
  103. 103 groupPurchase.buyCount = @"32";
  104. 104
  105. 105 // 加入新数据
  106. 106 NSMutableArray *marray = [NSMutableArray arrayWithArray:self.groupPurchases];
  107. 107 [marray addObject:groupPurchase];
  108. 108 self.groupPurchases = marray;
  109. 109
  110. 110 // 刷新数据
  111. 111 [self.tableView reloadData];
  112. 112 }
  113. 113
  114. 114 // 配置一些头部广告的数据
  115. 115 - (HeaderAdView *) genAdView {
  116. 116 HeaderAdView *adView = [HeaderAdView headerAdView];
  117. 117
  118. 118 NSMutableArray *adImages = [NSMutableArray array];
  119. 119 for (int i=0; i<5; i++) {
  120. 120 [adImages addObject:[NSString stringWithFormat:@"ad_%02d", i]];
  121. 121 }
  122. 122
  123. 123 adView.ads = adImages;
  124. 124
  125. 125 return adView;
  126. 126 }
  127. 127
  128. 128 @end
 
2.自定义cell
 
  1. 1 //
  2. 2 // GroupPurchaseCell.m
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import "GroupPurchaseCell.h"
  10. 10 #import "GroupPurchase.h"
  11. 11
  12. 12 @implementation GroupPurchaseCell
  13. 13
  14. 14 // 界面被初始化的时候调用 awakeFromNib
  15. 15 - (void)awakeFromNib {
  16. 16 // Initialization code
  17. 17 }
  18. 18
  19. 19 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  20. 20 [super setSelected:selected animated:animated];
  21. 21
  22. 22 // Configure the view for the selected state
  23. 23 }
  24. 24
  25. 25 /** 自定初始化的类方法,传入model数据 */
  26. 26 + (instancetype) groupPurchaseCellWithTableView:(UITableView *) tableView {
  27. 27
  28. 28 static NSString *ID = @"groupPurchase";
  29. 29
  30. 30 // 从缓存池寻找
  31. 31 GroupPurchaseCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  32. 32
  33. 33 // 若缓存池没有,则创建一个
  34. 34 if (nil == cell) {
  35. 35 cell = [[[NSBundle mainBundle] loadNibNamed:@"GroupPurchaseCell" owner:nil options:nil] lastObject];
  36. 36 }
  37. 37
  38. 38 return cell;
  39. 39 }
  40. 40
  41. 41 /** 加载Model数据,初始化界面 */
  42. 42 - (void) setGroupPurchase:(GroupPurchase *) groupPurchase {
  43. 43 if (nil != groupPurchase) {
  44. 44 self.titleLabel.text = groupPurchase.title;
  45. 45 self.iconImageView.image = [UIImage imageNamed:groupPurchase.icon];
  46. 46 self.priceLabel.text = [NSString stringWithFormat:@"¥%@", groupPurchase.price];
  47. 47 self.buyCountLabel.text = [NSString stringWithFormat:@"%@人已经购买", groupPurchase.buyCount];
  48. 48 }
  49. 49
  50. 50 _groupPurchase = groupPurchase;
  51. 51 }
  52. 52
  53. 53 @end
  54. 54
 
3.底部加载按钮
 
  1. 1 //
  2. 2 // FooterRefreshView.h
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import <UIKit/UIKit.h>
  10. 10
  11. 11 @class FooterRefreshView;
  12. 12
  13. 13 // 定义delegate协议
  14. 14 @protocol FooterRefreshViewDelegate <NSObject>
  15. 15
  16. 16 @optional
  17. 17 - (void) footerRefreshViewClickedFooterRefreshButton:(FooterRefreshView *) footerRefreshView;
  18. 18
  19. 19 @end
  20. 20
  21. 21 @interface FooterRefreshView : UIView
  22. 22
  23. 23 // 带代理的初始化方法
  24. 24 + (instancetype) footerRrefreshViewWithDelegate:(id<FooterRefreshViewDelegate>) delegate;
  25. 25
  26. 26 @end
  1. 1 //
  2. 2 // FooterRefreshView.m
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import "FooterRefreshView.h"
  10. 10
  11. 11 @interface FooterRefreshView()
  12. 12 /** 底部的“加载更多”按钮 */
  13. 13 @property (weak, nonatomic) IBOutlet UIButton *footerRefreshButton;
  14. 14
  15. 15 /** 加载动画图标 */
  16. 16 @property (weak, nonatomic) IBOutlet UIActivityIndicatorView *loadingImage;
  17. 17
  18. 18 /** 代理 */
  19. 19 @property(nonatomic, weak) id<FooterRefreshViewDelegate> delegate;
  20. 20
  21. 21 /** “加载更多”按钮点击事件 */
  22. 22 - (IBAction)onFooterRefreshButtonClicked;
  23. 23
  24. 24
  25. 25 @end
  26. 26
  27. 27 @implementation FooterRefreshView
  28. 28
  29. 29 #pragma mark - 初始化
  30. 30
  31. 31 /** 初始化方法 */
  32. 32 + (instancetype) footerRrefreshViewWithDelegate:(id<FooterRefreshViewDelegate>) delegate {
  33. 33 FooterRefreshView *footerRefreshView = [[[NSBundle mainBundle] loadNibNamed:@"FooterRefreshView" owner:nil options:nil] lastObject];
  34. 34
  35. 35 if (nil != delegate) {
  36. 36 footerRefreshView.delegate = delegate;
  37. 37 }
  38. 38
  39. 39 return footerRefreshView;
  40. 40 }
  41. 41
  42. 42 // xib控件的初始化调用方法
  43. 43 - (void)awakeFromNib {
  44. 44 self.loadingImage.hidden = YES;
  45. 45 }
  46. 46
  47. 47
  48. 48 #pragma mark - action
  49. 49 /** “加载更多”按钮点击事件 */
  50. 50 - (IBAction)onFooterRefreshButtonClicked {
  51. 51 NSString *footerButtonTitle = self.footerRefreshButton.currentTitle;
  52. 52
  53. 53 // 显示正在加载
  54. 54 self.loadingImage.hidden = NO;
  55. 55 [self.footerRefreshButton setTitle:@"拼命加载中..." forState:UIControlStateNormal];
  56. 56
  57. 57 // 暂时禁止按钮事件
  58. 58 self.footerRefreshButton.userInteractionEnabled = NO;
  59. 59
  60. 60 // 模拟延迟
  61. 61 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  62. 62 // 通知代理发生了点击事件
  63. 63 if ([self.delegate respondsToSelector:@selector(footerRefreshViewClickedFooterRefreshButton:)]) {
  64. 64 [self.delegate footerRefreshViewClickedFooterRefreshButton:self];
  65. 65 }
  66. 66
  67. 67 // 恢复按钮状态
  68. 68 self.footerRefreshButton.userInteractionEnabled = YES;
  69. 69 self.loadingImage.hidden = YES;
  70. 70 [self.footerRefreshButton setTitle:footerButtonTitle forState:UIControlStateNormal];
  71. 71 });
  72. 72
  73. 73 }
  74. 74
  75. 75 @end
 
4.头部广告
 
  1. 1 //
  2. 2 // HeaderAdView.h
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import <UIKit/UIKit.h>
  10. 10
  11. 11 @interface HeaderAdView : UIView
  12. 12 // 广告组
  13. 13 @property(nonatomic, strong) NSArray *ads;
  14. 14
  15. 15 + (instancetype) headerAdView;
  16. 16
  17. 17 @end
 
  1. 1 //
  2. 2 // HeaderAdView.m
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import "HeaderAdView.h"
  10. 10
  11. 11 #define AD_VIEW_WIDTH 300
  12. 12 #define AD_VIEW_HEIGHT 120
  13. 13
  14. 14 // 遵守UIScrollViewDelegate监控滚动事件
  15. 15 @interface HeaderAdView() <UIScrollViewDelegate>
  16. 16
  17. 17 /** scrollView控件 */
  18. 18 @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
  19. 19
  20. 20 /** 页码 */
  21. 21 @property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
  22. 22
  23. 23 /** 计时器 */
  24. 24 @property(nonatomic, weak) NSTimer *timer;
  25. 25
  26. 26 @end
  27. 27
  28. 28 @implementation HeaderAdView
  29. 29
  30. 30 #pragma mark - 初始化方法
  31. 31 // 初始化headerAdView
  32. 32 + (instancetype) headerAdView {
  33. 33 return [[[NSBundle mainBundle] loadNibNamed:@"HeaderAdView" owner:nil options:nil] lastObject];
  34. 34 }
  35. 35
  36. 36 // 当控件从nib初始化
  37. 37 - (void)awakeFromNib {
  38. 38 self.scrollView.scrollEnabled = YES; // 开启滚动
  39. 39 self.scrollView.pagingEnabled = YES; // 开启翻页模式
  40. 40 self.scrollView.delegate = self;// 设置代理
  41. 41 }
  42. 42
  43. 43 /** 设置ads */
  44. 44 - (void) setAds:(NSArray *)ads {
  45. 45 if (nil != ads) {
  46. 46 CGFloat adImageWidth = AD_VIEW_WIDTH;
  47. 47 CGFloat adImageHeight = AD_VIEW_HEIGHT;
  48. 48 CGFloat adImageY = 0;
  49. 49
  50. 50 for (int i=0; i<ads.count; i++) {
  51. 51 // 计算当前图片的水平坐标
  52. 52 CGFloat adImageX = i * adImageWidth;
  53. 53
  54. 54 UIImageView *adImageView = [[UIImageView alloc] initWithFrame:CGRectMake(adImageX, adImageY, adImageWidth, adImageHeight)];
  55. 55 adImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", ads[i]]];
  56. 56
  57. 57 [self.scrollView addSubview:adImageView];
  58. 58 }
  59. 59
  60. 60 // 设置滚动范围
  61. 61 self.scrollView.contentSize = CGSizeMake(ads.count * AD_VIEW_WIDTH, 0);
  62. 62
  63. 63 self.pageControl.numberOfPages = ads.count; // 总页数
  64. 64 self.pageControl.pageIndicatorTintColor = [UIColor blackColor]; // 其他页码颜色
  65. 65 self.pageControl.currentPageIndicatorTintColor = [UIColor redColor]; // 当前页码颜色
  66. 66
  67. 67 // 添加自动轮播
  68. 68 [self addTimer];
  69. 69 }
  70. 70
  71. 71 _ads = ads;
  72. 72 }
  73. 73
  74. 74 #pragma mark - 滚动事件
  75. 75 // 滚动动作监控,当滚动超过图片的一半的时候转变页码
  76. 76 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  77. 77 CGFloat scrollViewWidth = self.scrollView.frame.size.width;
  78. 78 int page = (self.scrollView.contentOffset.x + 0.5 * scrollViewWidth) / scrollViewWidth;
  79. 79 self.pageControl.currentPage = page;
  80. 80 }
  81. 81
  82. 82 // 手动拖动广告图片轮播的时候,暂时销毁自动轮播器
  83. 83 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  84. 84 [self.timer invalidate];
  85. 85 self.timer = nil;
  86. 86 }
  87. 87
  88. 88 // 手动拖动结束,从新加上自动轮播器
  89. 89 - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
  90. 90 [self addTimer];
  91. 91 }
  92. 92
  93. 93 // 添加计时器
  94. 94 - (void) addTimer {
  95. 95 self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];
  96. 96
  97. 97 // 计时器分享主线程资源
  98. 98 [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
  99. 99 }
  100. 100
  101. 101 // 下一张图片动作
  102. 102 - (void) nextImage {
  103. 103 int page = 0;
  104. 104 // 如果是当前页码在最后一页,从新回到第一页
  105. 105 if (self.pageControl.currentPage == self.ads.count - 1) {
  106. 106 page = 0;
  107. 107 }
  108. 108 else {
  109. 109 page = self.pageControl.currentPage + 1;
  110. 110 }
  111. 111
  112. 112 // 滚动图片,带动画效果
  113. 113 [self.scrollView setContentOffset:CGPointMake(page * AD_VIEW_WIDTH, 0) animated:YES];
  114. 114 }
  115. 115 @end
 
5.model
  1. 1 //
  2. 2 // GroupPurchase.h
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import <Foundation/Foundation.h>
  10. 10
  11. 11 @interface GroupPurchase : NSObject
  12. 12
  13. 13 /** 图片 */
  14. 14 @property(nonatomic, copy) NSString *icon;
  15. 15
  16. 16 /** 标题 */
  17. 17 @property(nonatomic, copy) NSString *title;
  18. 18
  19. 19 /** 已经购买人数 */
  20. 20 @property(nonatomic, copy) NSString *buyCount;
  21. 21
  22. 22 /** 价格 */
  23. 23 @property(nonatomic, copy) NSString *price;
  24. 24
  25. 25 //初始化方法
  26. 26 - (instancetype) initWithDictionary:(NSDictionary *) dictionary;
  27. 27 + (instancetype) groupPurchaseWithDictionary:(NSDictionary *) dictionary;
  28. 28 + (instancetype) groupPurchase;
  29. 29
  30. 30 @end
 
  1. 1 //
  2. 2 // GroupPurchase.m
  3. 3 // GroupPurchase
  4. 4 //
  5. 5 // Created by hellovoidworld on 14/12/3.
  6. 6 // Copyright (c) 2014年 hellovoidworld. All rights reserved.
  7. 7 //
  8. 8
  9. 9 #import "GroupPurchase.h"
  10. 10
  11. 11 @implementation GroupPurchase
  12. 12
  13. 13 //初始化方法
  14. 14 - (instancetype) initWithDictionary:(NSDictionary *) dictionary
  15. 15 {
  16. 16 if (self = [super init]) {
  17. 17 // 使用KVC
  18. 18 [self setValuesForKeysWithDictionary:dictionary];
  19. 19 }
  20. 20
  21. 21 return self;
  22. 22 }
  23. 23
  24. 24 + (instancetype) groupPurchaseWithDictionary:(NSDictionary *) dictionary {
  25. 25 return [[self alloc] initWithDictionary:dictionary];
  26. 26 }
  27. 27
  28. 28 + (instancetype) groupPurchase {
  29. 29 return [self groupPurchaseWithDictionary:nil];
  30. 30 }
  31. 31
  32. 32 @end
 
6.plist文件结构
 

[iOS基础控件 - 6.6.1] 展示团购数据代码的更多相关文章

  1. [iOS基础控件 - 6.7] 微博展示 使用代码自定义TableCell(动态尺寸)

    A.需求 1.类似于微博内容的展示 2.头像 3.名字 4.会员标志 5.内容 6.分割线 7.配图(可选,可有可无)   code source: https://github.com/hellov ...

  2. [iOS基础控件 - 5.2] 查看大图、缩放图片代码(UIScrollView制作)

    原图: 900 x 1305      拖曳滚动:   缩放:           主要代码: // // ViewController.m // ImageZoom // // Created by ...

  3. [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)

    A.概述      在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能      1.按钮点击后,显示为“已下载”,并且不 ...

  4. [iOS基础控件 - 6.7.1] 微博展示 代码

      Controller: // // ViewController.m // Weibo // // Created by hellovoidworld on 14/12/4. // Copyrig ...

  5. [iOS基础控件 - 6.6] 展示团购数据 自定义TableViewCell

    A.需求 1.头部广告 2.自定义cell:含有图片.名称.购买数量.价格 3.使用xib设计自定义cell,自定义cell继承自UITableViewCell 4.尾部“加载更多按钮”,以及其被点击 ...

  6. iOS 基础控件(下)

    上篇介绍了UIButton.UILabel.UIImageView和UITextField,这篇就简短一点介绍UIScrollView和UIAlertView. UIScrollView 顾名思义也知 ...

  7. [iOS基础控件 - 6.9] 聊天界面Demo

    A.需求 做出一个类似于QQ.微信的聊天界面 1.每个cell包含发送时间.发送人(头像).发送信息 2.使用对方头像放在左边,我方头像在右边 3.对方信息使用白色背景对话框,我方信息使用蓝色背景对话 ...

  8. [iOS基础控件 - 7.0] UIWebView

    A.基本使用 1.概念 iOS内置的浏览器控件 Safari浏览器就是通过UIWebView实现的   2.用途:制作简易浏览器 (1)基本请求 创建请求 加载请求 (2)代理监听webView加载, ...

  9. [iOS基础控件 - 6.11.3] 私人通讯录Demo 控制器的数据传递、存储

    A.需求 1.搭建一个"私人通讯录"Demo 2.模拟登陆界面 账号 密码 记住密码开关 自动登陆开关 登陆按钮 3.退出注销 4.增删改查 5.恢复数据(取消修改)   这个代码 ...

随机推荐

  1. c缺陷与陷阱笔记-第一章 词法陷阱

    1.运算符的贪心性,匹配最长的运算符,例如 n-->0,从-开始,-是运算符,--是运算符,-->就不是,所以是 n -- > 0,--是 a---b,-是,--是,,---不是,所 ...

  2. A过的题目

    1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...

  3. POJ3660——Cow Contest(Floyd+传递闭包)

    Cow Contest DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a prog ...

  4. P66、面试题8:旋转数组的最小数字

    题目:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转.输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素.例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数 ...

  5. socket关闭动作以及socket状态的总结

    主要部分,四次握手: 断开连接其实从我的角度看不区分客户端和服务器端,任何一方都可以调用close(or closesocket)之类的函数开始主动终止一个连接.这里先暂时说正常情况.当调用close ...

  6. Lambda表达式 =>(msdn)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 1671. Anansi's Cobweb(并查集)

    1671 并查集 对于询问删除边之后的连通块 可以倒着加边 最后再倒序输出 #include <iostream> #include<cstdio> #include<c ...

  8. innodb master主线程

    http://wenku.baidu.com/link?url=MhY9yhHTgeOlyooWDvaVfPkW3cuVSX_rIZv2QtCu7GLeEuqSfYh_M7Yvl1N4IY08a3ws ...

  9. Java内省

    什么是内省? Java语言对bean类属性.事件的一种缺省处理方法,例如类A中有属性name,那我们可以通过getName,setName来得到其值或者设置新的值. 什么是JavaBean? Java ...

  10. ajax withCredentials在firefox下问题的解释

    1,起因: 跨域的问题一般有两种解决方式比较常用,一是使用jsonp,二是服务端配置cors策略.至于jsonp这里不再赘述,本文主要解释一下cors解决跨域产生的问题 2,cors跨域产生的问题 j ...