语法 - If not let - in Swift
变更记录
序号
录入时间
录入人
备注
1
2015-04-13
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称语法 - If not let - in Swift
关键字语法 \ optional \ ? \ ! \ if let
需求场景
判断 optional 字段是否有效\无效时
参考链接
Stacck Overflow - If not let in Swift
详细内容正常的 if let 用法
12345if let type = json.type {} else { //There is no type in the root element}
if not let 实现
123456789101112func ifNotLet<T>(optional: T?, closure: @autoclosure () -> ()) -> T { switch optional { case .None ...
通知 - 远程推送通知(Remote Notification)的测试与实现
变更记录
序号
录入时间
录入人
备注
1
2015-04-22
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称通知 - 远程推送通知(Remote Notification)的测试与实现
关键字推送 \ Remote Notification \ 远程推送 \ 远程通知
需求场景
需要对 APP 的推送功能进行开发与测试时
参考链接
博客园 - iOS推送小结–swift语言
CocoaChina - (APNS) IOS远程推送测试工具SmartPush for Mac
使用pushmebaby测试app的远程推送功能
博客园 - Java实现IOS推送(Javapns2.2)
博客园 - 苹果推送通知服务教程 Apple Push Notification Services Tutorial
iPhone推送通知功能分析总结
《本地和推送通知编程指南》
详细内容1. iOS 端推送的注册与实现
注册相关推送证书(参考链接)
在 AppDelegate 中实现以下步骤
123456789101112131415 ...
UILabel - 显示多格式文本
变更记录
序号
录入时间
录入人
备注
1
2015-04-13
Alfred Jiang
-
2
2015-08-28
Alfred Jiang
-
3
2015-12-23
Alfred Jiang
-
3
2016-05-03
Alfred Jiang
增加 批量替换子字符串显示格式
方案名称UILabel - 显示多格式文本
关键字UILabel \ NSMutableAttributedString \ attributedText \ 批量替换
需求场景
需要显示一段多格式的文本
批量替换子字符串显示格式
参考链接
Stack Overflow - Change attributes of substrings in a NSAttributedString
详细内容1. Objective-C 示例显示富文本格式123456NSString *plainText = [NSString stringWithFormat:@"%@ test", @"click"];NSMutableAttributedS ...
UILabel - 悬浮美金单位效果的实现
变更记录
序号
录入时间
录入人
备注
1
2015-03-27
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称UILabel - 悬浮美金单位效果的实现
关键字UILabel \ 悬浮 \ 单位 \ 美金单位
需求场景
需要实现如效果图显示的特殊的美金单位显示效果时
参考链接(无)
详细内容
在 Xib 条件下,用于显示金额数字的 UILabelA 的 Autolayout 约束条件不要设置长度,这样 UILabelA 可以根据内容自动设置自己的长度;
设置显示 $ 的 UILabelB 尾部约束条件为距离 UILabelA 顶部 X个像素,这样最终就会显示出如图所示的效果
效果图
备注(无)
UIScrollView - 给 UIScrollView 添加 Autolayout 约束条件
变更记录
序号
录入时间
录入人
备注
1
2015-03-27
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称UIScrollView - 给 UIScrollView 添加 Autolayout 约束条件
关键字UIScrollView \ Autolayout \ 自适应大小的 UIScrollView
需求场景
一些应用的详情页面需要使用 UIScrollView 时
参考链接
iOS: How To Make AutoLayout Work On A ScrollView
详细内容#####1. 已纵向滑动为例
首先,在需要滑动显示的页面 Xib 主 View 下拖放一个 UIScrollView ,并设置约束条件为上下左右四个方向距离主 View 都为 0 ;
在 UIScrollView 中添加一个 UIView 作为 ContentView ,并设置约束条件为上下左右四个方向距离主 UIScrollView 都为 0 ;
同时选中 UIScrollView 和 ContentView ,通过 E ...
NSDate - 时间日期相关操作方法总结
变更记录
序号
录入时间
录入人
备注
1
2015-03-30
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称NSDate - 时间日期相关操作方法总结
关键字NSDate \ 时间操作 \ 日期
需求场景
需要用到日期显示和时间操作等场景时
参考链接
GitHub - DateTools
详细内容######1. 时间戳相关
获取当前时间戳
12345678910+ (NSTimeInterval)timeBySecond{ NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; return [dat timeIntervalSince1970];}+ (NSString *)stringTimeBySecond{ return [NSString stringWithFormat:@"%.0f", [[self class] timeBySecond]];}
NSDate 与 ...
相册 - 从系统相册选择照片
变更记录
序号
录入时间
录入人
备注
1
2015-03-01
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称相册 - 从系统相册选择照片
关键字相册 \ 拍照 \ 照片选取 \ ImagePickerController
需求场景
需要从系统相册选择照片的一类需求
参考链接
GitHub - JSImagePickerController
Kayo - iOS 开发之照片框架详解
详细内容使用方法:
复制 JSImagePickerViewController.h/m 文件即可,导入头文件:
1#import "JSImagePickerViewController.h"
示例代码:
123JSImagePickerViewController *imagePicker = [[JSImagePickerViewController alloc] init];imagePicker.delegate = self;[imagePicker showImagePickerInCont ...
UIPageControl - 翻页显示的实现
变更记录
序号
录入时间
录入人
备注
1
2015-03-30
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称UIPageControl - 翻页显示的实现
关键字UIPageControl \ 翻页 \ UIScrollView
需求场景
需要实现 UIScrollView 翻页显示并显示页码标签时
参考链接(无)
详细内容#####1. Swift 版本
1234567891011func scrollViewDidScroll(scrollView: UIScrollView) { self.resetPageControl()}func resetPageControl(){ var iPages : NSInteger = NSInteger(self.scrollViewAttachments.contentSize.width / self.scrollViewAttachments.frame.size.width) var iPage : NSInte ...
地图 - MKMapView 地图开发相关总结
变更记录
序号
录入时间
录入人
备注
1
2015-03-31
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称地图 - MKMapView 地图开发相关总结
关键字MKMapView \ CLLocationCoordinate2D \ CLLocation
需求场景
需要实现地图显示需求时
参考链接(无)
详细内容#####1. 坐标
CLLocationCoordinate2D 与 NSString 之间的相互转换123456789101112131415+ (CLLocationCoordinate2D) get2DCoordFromString:(NSString*)coordString{ CLLocationCoordinate2D location; NSArray *coordArray = [coordString componentsSeparatedByString: @","]; location.latitude = ((NSNumber * ...
UILabel - 通过字符串长度计算显示框大小的方法
变更记录
序号
录入时间
录入人
备注
1
2015-03-31
Alfred Jiang
-
2
2015-12-23
Alfred Jiang
-
方案名称UILabel - 通过字符串长度计算显示框大小的方法
关键字UILabel \ Size \ UITextView \ CGSize \ CGFrame
需求场景
根据一段文字动态计算出用于显示的 UILabel 或 UITextView 等控件的显示大小
参考链接Swift 版本Objective-C 版本1234567891011121314+ (CGSize)string:(NSString *)string rectSize:(CGSize)upperSize font:(UIFont *)aFont{ NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:aFont, NSFontAttributeName, nil]; CGSize size = [string boundingRectWithSize ...