Contents
  1. 1. 项目中用过的
    1. 1.1. GMImagePicker
    2. 1.2. MBProgressHUD
    3. 1.3. ZipArchive
  2. 2. 想用但是放弃的
    1. 2.1. iCarousel
    2. 2.2. Material-Controls-For-iOS
    3. 2.3. ios-material-design
  3. 3. 外部链接
  4. 4. 附iOS尺寸规范

项目中用过的

使用一些集成库能帮你节省下大量的时间和代码量。

3.17 更新:添加测试使用的库 Reachability

GMImagePicker

iOS上的图片多选view,用GMImagePickerControllerDelegate中的

1
- (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickingAssets:(NSArray *)assetArray;

方法拿到assetArray转型为PHAsset组

1
2
3
4
5
[[PHImageManager defaultManager] requestImageDataForAsset:asset
options:imageRequestOptions
resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
// Do something with imageData...
}];

拿到每张图片的NSData,保存在本地沙盒中

MBProgressHUD

在需要花费较长时间的事件处理过程中,为了防止用户误操作,将用户界面锁定并显示进度条或提示。(锁定主线程,直到异步事件处理完毕)

1
2
3
4
5
6
7
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
// Do something...
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
});

If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns.

1
2
3
4
5
6
7
8
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeAnnularDeterminate;
hud.labelText = @"Loading";
[self doSomethingInBackgroundWithProgressCallback:^(float progress) {
hud.progress = progress;
} completionCallback:^{
[hud hide:YES];
}];

ZipArchive

注意,不是重写过的 SSZipArchive

Google写的zip解压缩工具,用于一次上传多个文件。注意在向zip添加文件的时候文件必须要在沙盒路径下,否则绝对路径只能读出(null)。(大坑,也是没有系统、基础的学习iOS的漏洞。)

tip:临时文件本身可以放在tmp文件下,作为自动处理的缓存,启动APP时会自动清理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- (NSString *) GetZip{
ZipArchive* zip = [[ZipArchive alloc] init];
NSString *documentPath = NSTemporaryDirectory();
NSString* l_zipfile = [NSString stringWithFormat:@"%@/tmp.zip",documentPath];
BOOL ret = [zip CreateZipFile2:l_zipfile];
for (int i=0; i<imagesArray.count; i++) {
NSString *imgURL = imagesArray[i];
ret = [zip addFileToZip:imgURL newname:[NSString stringWithFormat:@"%d.PNG",i]];
}
if( ![zip CloseZipFile2] )
{
l_zipfile = @"";
}
return l_zipfile;
// [zip release];
}

想用但是放弃的

iCarousel

一个比较有名的旋转式选择界面库,可以使用它做出格式各样的3D选择界面,可以100%还原iPhone原生的app选择界面

Material-Controls-For-iOS

仿照Android的原生Material样式的各种控件和逻辑过渡的重写,

ios-material-design

点击view的某处或者button会用波浪式的颜色渲染过渡,很炫。

外部链接

Reachability: tonymillion/Reachability
用于检测当前网络状态

ZipArchive: mattconnolly/ZipArchive
只需要其中的miniZip, ZipArchive.h和ZipArchive.m

GMImagePicker: guillermomuntaner/GMImagePicker

MBProgressHUD: jdg/MBProgressHUD

Material-Controls-For-iOS: fpt-software/Material-Controls-For-iOS

ios-material-design: moqod/ios-material-design

iCarousel: nicklockwood/iCarousel

附iOS尺寸规范

设备

iPhone

Width

Height

对角线

Diagonal

逻辑分辨率(point)

Scale Factor

设备分辨率(pixel)

PPI

3GS

2.4 inches (62.1 mm)

4.5 inches (115.5 mm)

3.5-inch

 

320x480

@1x

320x480

163

4(s)

2.31 inches (58.6 mm)

4.5 inches (115.2 mm)

3.5-inch

320x480

@2x

640x960

326

5c

2.33 inches (59.2 mm)

4.90 inches (124.4 mm)

4-inch

320x568

@2x

640x1136

326

5(s)

2.31 inches (58.6 mm)

4.87 inches (123.8 mm)

4-inch

320x568

@2x

640x1136

326

6

2.64 inches (67.0 mm)

5.44 inches (138.1 mm)

4.7-inch

375x667

@2x

750x1334

326

6+

3.06 inches (77.8 mm)

6.22 inches (158.1 mm)

5.5-inch

414x736

@3x

(1242x2208->)

1080x1920

401 

Contents
  1. 1. 项目中用过的
    1. 1.1. GMImagePicker
    2. 1.2. MBProgressHUD
    3. 1.3. ZipArchive
  2. 2. 想用但是放弃的
    1. 2.1. iCarousel
    2. 2.2. Material-Controls-For-iOS
    3. 2.3. ios-material-design
  3. 3. 外部链接
  4. 4. 附iOS尺寸规范