孙同生的博客

为美好的世界献上祝福

  • 首页
  • 标签
  • 分类
  • 归档
  • d3学习demo演示
  • 搜索

SDWebImage375源码-简介

发表于 2016-10-10 | 更新于 2018-11-23 | 分类于 essay , SDWebImage | 评论数: | 阅读次数:
本文字数: 14k | 阅读时长 ≈ 13 分钟

SDWebImage 3.7.5简介

github地址: https://github.com/rs/SDWebImage

功能

  • 异步图片下载
  • 异步图片缓存
  • GIF支持
  • WebP图片格式支持
  • 后台图片解析
  • 相同URL不会被多次下载
  • 无效URL不会多次尝试链接
阅读全文 »

SDWebImage375源码-贰

发表于 2016-10-10 | 更新于 2018-11-23 | 分类于 essay , SDWebImage | 评论数: | 阅读次数:
本文字数: 24k | 阅读时长 ≈ 22 分钟

3. downloadImageWithURL下载方法的具体实现

方法在SDWebImageManager.m中

1
2
3
4
id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url 	
options:(SDWebImageOptions)options
progress:(SDWebImageDownloaderProgressBlock)progressBlock
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock

参数:

  • url
  • options
    • 之前已经介绍了 SDWebImageOptions
  • progressBlock
    • SDWebImageDownloaderProgressBlock 定义在 SDWebImageDownloader.h 中具体实现为:
      1
      2
      3
      //从名字可以看出来第一个参数是已经接受了数据的大小
      //另一个参数表示总数据的大小
      typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
  • completedBlock
    • 图片下载完要做的块 具体实现为:
      1
      2
      		
      typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL);

然后一看这个方法实现……麻蛋 好长!

阅读全文 »

AVFoundation-AVAudioPlayer简介

发表于 2016-10-10 | 更新于 2018-11-23 | 分类于 essay , AVFoundation | 评论数: | 阅读次数:
本文字数: 6.9k | 阅读时长 ≈ 6 分钟

使用System Sound Service播放音效

参考

步骤

  1. 调用AudioServicesCreateSystemSoundID( CFURLRef inFileURL, SystemSoundID* outSystemSoundID)函数获得系统声音ID。
  2. 如果需要监听播放完成操作,则使用AudioServicesAddSystemSoundCompletion( SystemSoundID inSystemSoundID, CFRunLoopRef inRunLoop, CFStringRef inRunLoopMode, AudioServicesSystemSoundCompletionProc inCompletionRoutine, void* inClientData)方法注册回调函数。
  3. 调用AudioServicesPlaySystemSound(SystemSoundID inSystemSoundID) 或者AudioServicesPlayAlertSound(SystemSoundID inSystemSoundID) 方法播放音效(后者带有震动效果)。
阅读全文 »

AVFoundation-avspeechsynthesizer文字转语音

发表于 2016-10-10 | 更新于 2018-11-23 | 分类于 essay , AVFoundation | 评论数: | 阅读次数:
本文字数: 2.2k | 阅读时长 ≈ 2 分钟

AVSpeechSynthesizer 文字转语音

简单示例:

1
2
3
4
5

AVSpeechSynthesizer *synthesizer = [AVSpeechSynthesizer new];
AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc] initWithString:@"需要转化的文字"];
//语音合成器会生成音频
[synthesizer speakUtterance:utterance];

指定声音:

阅读全文 »

SDWebImage375源码-壹

发表于 2016-10-10 | 更新于 2018-11-23 | 分类于 essay , SDWebImage | 评论数: | 阅读次数:
本文字数: 21k | 阅读时长 ≈ 19 分钟

0. 图片的异步下载

比如在tableview中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString* cellID = @"cellID";

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}

[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"1.jpg"]];
cell.textLabel.text = @" text ";

return cell;

}
阅读全文 »
<i class="fa fa-angle-left" aria-label="上一页"></i>1…89
SunTongSheng

SunTongSheng

移动端 前端 跨平台

85 日志
22 分类
27 标签
RSS
© 2026 SunTongSheng | 532k | 8:04