学习带图片的列表

官方 LazyTableImages demo  http://download.csdn.net/detail/jlyidianyuan/5726749

分析源码是学习的好方法。

源码结构如上,不能运行,加红框内容。

项目结构

挨个看源文件

  1. /*
  2. Copyright (C) 2017 Apple Inc. All Rights Reserved.
  3. See LICENSE.txt for this sample’s licensing information
  4.  
  5. Abstract:
  6. Application delegate for the LazyTableImages sample.
  7. It also downloads in the background the "Top Paid iPhone Apps" RSS feed using NSURLSession/NSURLSessionDataTask.
  8. */
  9.  
  10. #import "LazyTableAppDelegate.h"
  11. #import "RootViewController.h"
  12. #import "ParseOperation.h"
  13. #import "AppRecord.h"
  14.  
  15. // the http URL used for fetching the top iOS paid apps on the App Store
  16. static NSString *const TopPaidAppsFeed =
  17. @"http://phobos.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/limit=75/xml";
  18.  
  19. @interface LazyTableAppDelegate ()
  20.  
  21. // the queue to run our "ParseOperation" NSOperationQueue解析队q列,类似java线程池
  22. @property (nonatomic, strong) NSOperationQueue *queue;
  23.  
  24. // the NSOperation driving the parsing of the RSS feed 解析类操作
  25. @property (nonatomic, strong) ParseOperation *parser;
  26.  
  27. @end
  28.  
  29. #pragma mark -
  30.  
  31. @implementation LazyTableAppDelegate
  32.  
  33. // The app delegate must implement the window @property
  34. // from UIApplicationDelegate @protocol to use a main storyboard file.
  35. //
  36. @synthesize window;
  37.  
  38. // -------------------------------------------------------------------------------
  39. // application:didFinishLaunchingWithOptions:
  40. // -------------------------------------------------------------------------------
  41. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  42. {
  43. //实例化联网请求
  44. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]];
  45.  
  46. // create an session data task to obtain and the XML feed
  47. // 使用9.0以后的联网操作类,之前可能使用NSURLConnection
  48. NSURLSessionDataTask *sessionTask =
  49. [[NSURLSession sharedSession] dataTaskWithRequest:request
  50. completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  51. // 获取联网状态代码 200 ,300,400,500等
  52. // in case we want to know the response status code
  53. //NSInteger HTTPStatusCode = [(NSHTTPURLResponse *)response statusCode];
  54.  
  55. if (error != nil)//如果有错误
  56. {
  57. [[NSOperationQueue mainQueue] addOperationWithBlock: ^{
  58. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  59.  
  60. if ([error code] == NSURLErrorAppTransportSecurityRequiresSecureConnection)
  61. {
  62. // if you get error NSURLErrorAppTransportSecurityRequiresSecureConnection (-1022),
  63. // then your Info.plist has not been properly configured to match the target server.
  64. //错误码含意查询:https://www.meiwen.com.cn/subject/jjjdnttx.html
  65. //在工程的 info.plist 文件中添加 https允许
  66. abort();
  67. }
  68. else
  69. {
  70. //其它错误交给handleError处理
  71. [self handleError:error];
  72. }
  73. }];
  74. }
  75. else
  76. {
  77. //没错误往下走
  78. // create the queue to run our ParseOperation 初始化解析队列
  79. self.queue = [[NSOperationQueue alloc] init];
  80.  
  81. // create an ParseOperation (NSOperation subclass) to parse the RSS feed data so that the UI is not blocked 初始化解析操作类
  82. _parser = [[ParseOperation alloc] initWithData:data];
  83. //__weak 弱引用,这里使用弱引用,防止线程引用对象造成内存泄漏。要回收LazyTableAppDelegate?真如此,程序已经结束。没必要了。
  84. __weak LazyTableAppDelegate *weakSelf = self;
  85. //添加解析错误时回调的block ,block 类似java interface 或者理解为内部类。好比java OnClickLister.
  86. self.parser.errorHandler = ^(NSError *parseError) {
  87. //dispatch_async GCD 方式在主线程上操作的方法。相关学习:线程如何操作主线程的3种方法.
  88. dispatch_async(dispatch_get_main_queue(), ^{
  89. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  90. //扔给本类的handleError方法处理。
  91. [weakSelf handleError:parseError];
  92. });
  93. };
  94.  
  95. // referencing parser from within its completionBlock would create a retain cycle
  96. __weak ParseOperation *weakParser = self.parser;
  97.  
  98. //解析完成返回处理
  99. self.parser.completionBlock = ^(void) {
  100. // The completion block may execute on any thread. Because operations
  101. // involving the UI are about to be performed, make sure they execute on the main thread.
  102. //结果需要在主线程更新
  103. dispatch_async(dispatch_get_main_queue(), ^{
  104. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  105. if (weakParser.appRecordList != nil)
  106. {
  107. //如果返回的解析集合不为空
  108. RootViewController *rootViewController =
  109. (RootViewController *)[(UINavigationController *)weakSelf.window.rootViewController topViewController];
  110. //RootViewController : UITableViewController 解析数据给到tableview
  111. rootViewController.entries = weakParser.appRecordList;
  112.  
  113. // tell our table view to reload its data, now that parsing has completed 更新tableview
  114. [rootViewController.tableView reloadData];
  115. }
  116. });
  117.  
  118. // we are finished with the queue and our ParseOperation
  119. weakSelf.queue = nil;
  120. };
  121.  
  122. [self.queue addOperation:self.parser]; // this will start the "ParseOperation"
  123. }
  124. }];
  125.  
  126. [sessionTask resume];
  127.  
  128. // show in the status bar that network activity is starting
  129. [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
  130.  
  131. return YES;
  132. }
  133.  
  134. // -------------------------------------------------------------------------------
  135. // handleError:error
  136. // Reports any error with an alert which was received from connection or loading failures.
  137. // -------------------------------------------------------------------------------
  138. - (void)handleError:(NSError *)error
  139. {
  140. NSString *errorMessage = [error localizedDescription];
  141.  
  142. // alert user that our current record was deleted, and then we leave this view controller
  143. //
  144. UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot Show Top Paid Apps", @"")
  145. message:errorMessage
  146. preferredStyle:UIAlertControllerStyleActionSheet];
  147. UIAlertAction *OKAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"")
  148. style:UIAlertActionStyleDefault
  149. handler:^(UIAlertAction *action) {
  150. // dissmissal of alert completed
  151. }];
  152.  
  153. [alert addAction:OKAction];
  154. [self.window.rootViewController presentViewController:alert animated:YES completion:nil];
  155. }
  156.  
  157. @end
  1. /*
  2. Copyright (C) 2017 Apple Inc. All Rights Reserved.
  3. See LICENSE.txt for this sample’s licensing information
  4.  
  5. Abstract:
  6. Controller for the main table view of the LazyTable sample.
  7. This table view controller works off the AppDelege's data model.
  8. produce a three-stage lazy load:
  9. 1. No data (i.e. an empty table)
  10. 2. Text-only data from the model's RSS feed
  11. 3. Images loaded over the network asynchronously
  12.  
  13. This process allows for asynchronous loading of the table to keep the UI responsive.
  14. Stage 3 is managed by the AppRecord corresponding to each row/cell.
  15.  
  16. Images are scaled to the desired height.
  17. If rapid scrolling is in progress, downloads do not begin until scrolling has ended.
  18. */
  19.  
  20. #import "RootViewController.h"
  21. #import "AppRecord.h"
  22. #import "IconDownloader.h"
  23.  
  24. #define kCustomRowCount 7
  25.  
  26. static NSString *CellIdentifier = @"LazyTableCell";
  27. static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";
  28.  
  29. #pragma mark -
  30.  
  31. @interface RootViewController () <UIScrollViewDelegate>
  32.  
  33. // the set of IconDownloader objects for each app
  34. @property (nonatomic, strong) NSMutableDictionary *imageDownloadsInProgress;
  35.  
  36. @end
  37.  
  38. #pragma mark -
  39.  
  40. @implementation RootViewController
  41.  
  42. // -------------------------------------------------------------------------------
  43. // viewDidLoad
  44. // -------------------------------------------------------------------------------
  45. - (void)viewDidLoad
  46. {
  47. [super viewDidLoad];
  48.  
  49. _imageDownloadsInProgress = [NSMutableDictionary dictionary];
  50. }
  51.  
  52. // -------------------------------------------------------------------------------
  53. // terminateAllDownloads
  54. // -------------------------------------------------------------------------------
  55. - (void)terminateAllDownloads
  56. {
  57. //停止下载
  58. // terminate all pending download connections
  59. NSArray *allDownloads = [self.imageDownloadsInProgress allValues];
  60. //数组的makeObjectsPerformSelector:SEL方法来减少自己写循环代码.让数组中每个对象都执行 cancelDownload 方法
  61. [allDownloads makeObjectsPerformSelector:@selector(cancelDownload)];
  62. //从字典移除记录。
  63. [self.imageDownloadsInProgress removeAllObjects];
  64. }
  65.  
  66. // -------------------------------------------------------------------------------
  67. // dealloc
  68. // If this view controller is going away, we need to cancel all outstanding downloads.
  69. // -------------------------------------------------------------------------------
  70. - (void)dealloc
  71. {
  72. // terminate all pending download connections
  73. [self terminateAllDownloads];
  74. }
  75.  
  76. // -------------------------------------------------------------------------------
  77. // didReceiveMemoryWarning
  78. // -------------------------------------------------------------------------------
  79. - (void)didReceiveMemoryWarning
  80. {
  81. [super didReceiveMemoryWarning];
  82.  
  83. // terminate all pending download connections
  84. [self terminateAllDownloads];
  85. }
  86.  
  87. #pragma mark - UITableViewDataSource
  88.  
  89. // -------------------------------------------------------------------------------
  90. // tableView:numberOfRowsInSection:
  91. // Customize the number of rows in the table view.
  92. // -------------------------------------------------------------------------------
  93. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  94. {
  95. NSUInteger count = self.entries.count;
  96.  
  97. // if there's no data yet, return enough rows to fill the screen
  98. if (count == )
  99. {
  100. return kCustomRowCount;
  101. }
  102. return count;
  103. }
  104.  
  105. // -------------------------------------------------------------------------------
  106. // tableView:cellForRowAtIndexPath:
  107. // -------------------------------------------------------------------------------
  108. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  109. {
  110. UITableViewCell *cell = nil;
  111.  
  112. NSUInteger nodeCount = self.entries.count;
  113.  
  114. if (nodeCount == && indexPath.row == )
  115. {
  116. // add a placeholder cell while waiting on table data 在storyboard中定义的加载中...
  117. cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier forIndexPath:indexPath];
  118. }
  119. else
  120. {
  121. cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  122.  
  123. // Leave cells empty if there's no data yet
  124. if (nodeCount > )
  125. {
  126. // Set up the cell representing the app
  127. AppRecord *appRecord = (self.entries)[indexPath.row];
  128.  
  129. cell.textLabel.text = appRecord.appName;
  130. cell.detailTextLabel.text = appRecord.artist;
  131.  
  132. // Only load cached images; defer new downloads until scrolling ends
  133. //这里注释得很明白,只加载cached(已缓存的)图片。
  134. //【defer】 英[dɪˈfɜː(r)] ,美[dɪˈfɜːr] ,v.推迟; 延缓; 展期;
  135. if (!appRecord.appIcon)//如果为空
  136. {
  137. if (self.tableView.dragging == NO && self.tableView.decelerating == NO)
  138. {
  139. //如果没有拖动,也没在惯性滑动。开始下载。
  140. [self startIconDownload:appRecord forIndexPath:indexPath];
  141. }
  142. // if a download is deferred or in progress, return a placeholder image
  143. //如果正在下载中给一个默认图。
  144. cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];
  145. }
  146. else
  147. {
  148. // (self.entries)[indexPath.row]; 直接使用
  149. cell.imageView.image = appRecord.appIcon;
  150. }
  151. }
  152. }
  153.  
  154. return cell;
  155. }
  156.  
  157. #pragma mark - Table cell image support
  158.  
  159. // -------------------------------------------------------------------------------
  160. // startIconDownload:forIndexPath: 第N个Cell的下载图片资源
  161. // -------------------------------------------------------------------------------
  162. - (void)startIconDownload:(AppRecord *)appRecord forIndexPath:(NSIndexPath *)indexPath
  163. {
  164. IconDownloader *iconDownloader = (self.imageDownloadsInProgress)[indexPath];
  165. if (iconDownloader == nil)
  166. {
  167. iconDownloader = [[IconDownloader alloc] init];
  168. iconDownloader.appRecord = appRecord;
  169. [iconDownloader setCompletionHandler:^{
  170.  
  171. //图片加载完成时回调本段代码
  172.  
  173. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  174.  
  175. // Display the newly loaded image
  176. cell.imageView.image = appRecord.appIcon;
  177.  
  178. // Remove the IconDownloader from the in progress list.
  179. // This will result in it being deallocated. 从字典中把下载对象移除。之前是有记录要下载的。
  180. [self.imageDownloadsInProgress removeObjectForKey:indexPath];
  181.  
  182. }];
  183. //在开始下载后,把下载对象记录到字典管理。
  184. (self.imageDownloadsInProgress)[indexPath] = iconDownloader;
  185. [iconDownloader startDownload];
  186. }
  187. }
  188.  
  189. // -------------------------------------------------------------------------------
  190. // loadImagesForOnscreenRows
  191. // This method is used in case the user scrolled into a set of cells that don't
  192. // have their app icons yet.
  193. // -------------------------------------------------------------------------------
  194. - (void)loadImagesForOnscreenRows
  195. {
  196. if (self.entries.count > )
  197. {
  198. //获取tableview 当前可见的编号。indexPathsForVisibleRows
  199. NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
  200. for (NSIndexPath *indexPath in visiblePaths)
  201. {
  202. AppRecord *appRecord = (self.entries)[indexPath.row];
  203.  
  204. if (!appRecord.appIcon)
  205. // Avoid the app icon download if the app already has an icon
  206. // 如果没有图片 开始下载图片
  207. {
  208. [self startIconDownload:appRecord forIndexPath:indexPath];
  209. }
  210. }
  211. }
  212. }
  213.  
  214. #pragma mark - UIScrollViewDelegate
  215.  
  216. // -------------------------------------------------------------------------------
  217. // scrollViewDidEndDragging:willDecelerate:
  218. // Load images for all onscreen rows when scrolling is finished.
  219. // tableview 滚动结束事件回调。停下来时,加载当前屏的图片。
  220. // -------------------------------------------------------------------------------
  221. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
  222. {
  223. if (!decelerate)
  224. {
  225. [self loadImagesForOnscreenRows];
  226. }
  227. }
  228.  
  229. // -------------------------------------------------------------------------------
  230. // scrollViewDidEndDecelerating:scrollView
  231. // When scrolling stops, proceed to load the app icons that are on screen.
  232. // -------------------------------------------------------------------------------
  233. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  234. {
  235. //惯性滑动结束时,开始加载图片,同上。
  236. [self loadImagesForOnscreenRows];
  237. }
  238.  
  239. @end
  1. /*
  2. Copyright (C) 2017 Apple Inc. All Rights Reserved.
  3. See LICENSE.txt for this sample’s licensing information
  4.  
  5. Abstract:
  6. Helper object for managing the downloading of a particular app's icon.
  7. It uses NSURLSession/NSURLSessionDataTask to download the app's icon in the background if it does not
  8. yet exist and works in conjunction with the RootViewController to manage which apps need their icon.
  9. */
  10.  
  11. #import "IconDownloader.h"
  12. #import "AppRecord.h"
  13.  
  14. #define kAppIconSize 48
  15.  
  16. @interface IconDownloader ()
  17.  
  18. @property (nonatomic, strong) NSURLSessionDataTask *sessionTask;
  19.  
  20. @end
  21.  
  22. #pragma mark -
  23.  
  24. @implementation IconDownloader
  25.  
  26. // -------------------------------------------------------------------------------
  27. // startDownload
  28. // -------------------------------------------------------------------------------
  29. - (void)startDownload
  30. {
  31. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.appRecord.imageURLString]];
  32.  
  33. // create an session data task to obtain and download the app icon
  34. _sessionTask = [[NSURLSession sharedSession] dataTaskWithRequest:request
  35. completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  36. // 这里使用NSURLSessionDataTask 进行数据加载。@NSURLSession @NSURLSessionDataTask 属一个知识体系,可以系统学习。
  37. //_sessionTask 声明为了属性,目的是可以进行控制。
  38.  
  39. // in case we want to know the response status code
  40. //NSInteger HTTPStatusCode = [(NSHTTPURLResponse *)response statusCode];
  41.  
  42. if (error != nil)
  43. {
  44. if ([error code] == NSURLErrorAppTransportSecurityRequiresSecureConnection)
  45. {
  46. // if you get error NSURLErrorAppTransportSecurityRequiresSecureConnection (-1022),
  47. // then your Info.plist has not been properly configured to match the target server.
  48. //
  49. abort();
  50. }
  51. }
  52.  
  53. //以上代码好像是规范格式。
  54.  
  55. [[NSOperationQueue mainQueue] addOperationWithBlock: ^{
  56.  
  57. // Set appIcon and clear temporary data/image
  58. UIImage *image = [[UIImage alloc] initWithData:data];
  59.  
  60. if (image.size.width != kAppIconSize || image.size.height != kAppIconSize)
  61. {
  62. //对图片进行裁剪操作。
  63. CGSize itemSize = CGSizeMake(kAppIconSize, kAppIconSize);
  64. UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0f);
  65. CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
  66. [image drawInRect:imageRect];
  67. self.appRecord.appIcon = UIGraphicsGetImageFromCurrentImageContext();
  68. UIGraphicsEndImageContext();
  69. }
  70. else
  71. {
  72. self.appRecord.appIcon = image;
  73. }
  74.  
  75. //不如何image给到了appRecord数据模型。
  76.  
  77. // call our completion handler to tell our client that our icon is ready for display
  78. //通知加载完成
  79. if (self.completionHandler != nil)
  80. {
  81. self.completionHandler();
  82. }
  83. }];
  84. }];
  85.  
  86. //开启task
  87. [self.sessionTask resume];
  88. }
  89.  
  90. // -------------------------------------------------------------------------------
  91. // cancelDownload
  92. // -------------------------------------------------------------------------------
  93. - (void)cancelDownload
  94. {
  95. [self.sessionTask cancel];
  96. _sessionTask = nil;
  97. }
  98.  
  99. @end

代码比较简单

1.appdelegate 去下载数据并解析。并更新tableview

//RootViewController : UITableViewController 解析数据给到tableview

rootViewController.entries = weakParser.appRecordList;

2.使用 model给tableview展示。

@property (nonatomic, strong) NSString *appName;

@property (nonatomic, strong) UIImage *appIcon;

@property (nonatomic, strong) NSString *artist;

@property (nonatomic, strong) NSString *imageURLString;

@property (nonatomic, strong) NSString *appURLString;

appIcon开始时为空,当展示在屏幕时,起线程去加载。并记录在

self.imageDownloadsInProgress

第一个下载对应一个线程对象。

3.这个代码  UIImage 会不数增加,数量够多,内存肯定溢出。

所以需要图片的加载策略。图片的三级缓存可系统独立学习。

【iOS入门】UITableView加载图片的更多相关文章

  1. iOS - UITableView加载网络图片 cell适应图片高度

    使用xib创建自定制cell   显示图片   创建一个继承UITableViewCell的类   勾选xib 如下是xib创建图 xib 向.h拖拽一个关联线 .h .m 2.代码创建(使用三方适配 ...

  2. iOS NSOperation 异步加载图片 封装NSOperation 代理更新

    #import <Foundation/Foundation.h> @class MYOperation; @protocol MYOperationDelecate <NSObje ...

  3. iOS之UITableView加载网络图片cell自适应高度

    #pragma mark- UITableView - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSI ...

  4. iOS 14 YYAnimatedImageView加载图片失败处理

    1.问题出在YYAnimatedImageView源码一个方法中 - (void)displayLayer:(CALayer *)layer { if (_curFrame) { layer.cont ...

  5. IOS UITableView 加载未知宽高图片的解决方案

    在开发中遇到了UITableView列表 UITableViewCell装载图片但不知Image的宽高 问题. 在解决该问题的时候,首先想到的是异步加载图片 采用第三方框架SDWebImage 实现对 ...

  6. ios UITableView 异步加载图片并防止错位

    UITableView 重用 UITableViewCell 并异步加载图片时会出现图片错乱的情况 对错位原因不明白的同学请参考我的另外一篇随笔:http://www.cnblogs.com/lesl ...

  7. IOS中UITableView异步加载图片的实现

    本文转载至 http://blog.csdn.net/enuola/article/details/8639404  最近做一个项目,需要用到UITableView异步加载图片的例子,看到网上有一个E ...

  8. iOS网络加载图片缓存与SDWebImage

    加载网络图片可以说是网络应用中必备的.如果单纯的去下载图片,而不去做多线程.缓存等技术去优化,加载图片时的效果与用户体验就会很差. 一.自己实现加载图片的方法 tips: *iOS中所有网络访问都是异 ...

  9. iOS: imageIO完成渐进加载图片

    imageIO完成渐进加载图片 不得不说,人都是有惰性的,一个月又快结束了,这个月虽说有点儿忙,但是绝对不差写几篇博客的时间,有时间去n次桌球厅,有时间玩n把英雄联盟,所谓小撸怡情大撸伤身,这个月游戏 ...

随机推荐

  1. MFC 屏蔽esc跟enter键

    BOOL CMenuOperate::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN && pMs ...

  2. windows Driver 查询指定键值

    NTSTATUS status; HANDLE hKey = NULL; OBJECT_ATTRIBUTES oa; UNICODE_STRING strPath = RTL_CONSTANT_STR ...

  3. Java算法练习——整数反转

    题目链接 题目描述 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转. 备注 注意: 假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为 $[−2^{31}, 2^ ...

  4. discuz伪静态问题(简单)

    提前声明一下我用的是宝塔面板.Linux系统.Nginx Web Server.经过一上午的摸索(我很菜了),终于在一个很无语的地方成功搞了伪静态1.2.点击查看当前的 Rewrite 规则3.我的是 ...

  5. spring boot 环境配置(profile)切换

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  6. Gym - 101142C CodeCoder vs TopForces(搜索)

    题意:给定n个人在两个网站上的得分,一个人若能在任意一个网站里战胜另一个人,则认为这个人能战胜那个人.问每个人都能战胜多少人. 分析: 1.战胜具有传递性. 例如: 4 5 2 7 3 3 因为第三个 ...

  7. caffe + ssd网络训练过程

    參考博客:https://blog.csdn.net/xiao_lxl/article/details/79106837 1获取源代码:git clone https://github.com/wei ...

  8. 转载电子发烧友网---STM32的IO口灌入电流和输出驱动电流

    刚开始学习一款单片机的时候一般都是从操作IO口开始的,所以我也一样,先是弄个流水灯. 刚开始我对STM32的认识不够,以为是跟51单片机类似,可以直接操作端口,可是LED灯却没反应,于是乎,仔细查看资 ...

  9. JSP编码问题解决方法

    最近再看JSP相关知识,被中文乱码搞的很头大.找了好多方法终于找到了一个简单可行的方案. JSP中request和response操作默认编码为"ISO-8859-1",这是中文乱 ...

  10. C++中substr()详解

    #include<string> #include<iostream> using namespace std; int main() { string s("123 ...