(raywenderlich.com使用2个空格) 方法大括号和其他大括号(if/else/switch/while 等.)总是在同一行语句打开但在新行中关闭。...)tag; - (instancetype)initWithWidth:(CGFloat)width height:(CGFloat)height; 不应该: -(void)setT:(NSString...通过使用’back’属性(_variable,变量名前面有下划线)直接访问实例变量应该尽量避免,除了在初始化方法(init, initWithCoder:, 等…),dealloc 方法和自定义的setters...应该: static NSString * const RWTAboutViewControllerCompanyName = @"RayWenderlich.com"; static CGFloat...这样确保编译器正确地推断结果类型。
提取手机号码 +(NSString*)getPhoneNoWithLength:(NSInteger)length WithStr:(NSString*)truePhone{...return [SVProgressHUD showInfoWithStatus:@"商户详细地址限制10-100 个字符"]; } 计算个数 + (CGFloat...)TextCountWithStr:(NSString *)s { // NSInteger MaxNumberOfDescriptionChars = _model.titleMaxCount...; int i;CGFloat n=[s length],l=0,a=0,b=0; CGFloat wLen=0; unichar c; for(i=0;i<n..._subLength=0; return 0;//只有isblank } else{ return wLen;//长度,中文占1,英文等能转
的一些常用方法总结了一下,这篇将tableView的代理方法作了总结,对上一篇博客进行了补充。...; 返回每个分区头部的标题 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)...section; 返回每个分区的尾部标题 - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger...)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)...)section; - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
1.磁盘总空间大小 + (CGFloat)diskOfAllSizeMBytes { CGFloat size = 0.0; NSError *error; NSDictionary...)diskOfFreeSizeMBytes { CGFloat size = 0.0; NSError *error; NSDictionary *dic = [[NSFileManager...objectForKey:NSFileSystemFreeSize]; size = [number floatValue]/1024/1024; } return size; } 3.将字符串数组按照元素首字母顺序进行排序分组...lastIndex = -1; for (int i = 0; i < array.count; i++) { NSInteger index = [indexedCollation...dic = [NSMutableDictionary dictionary]; [dic setObject:objects forKey:keys]; return dic; } 4.将字符串数组按照元素首字母顺序进行排序分组
NSInteger appH = 120; // 定义格子的总数量 NSInteger countOfApps = 80; // 定义一行有几个格子 NSInteger...每行的个数 NSUInteger col = i % numberOfCol; // 计算X = 左边间距 + (格子的宽 + 格子之间的间距) * 列号 CGFloat...列数 NSUInteger row = i / numberOfCol; // 计算格子的Y = 顶部间距 + (格子的高 + 格子之间间距) * 行号 CGFloat...如: dict[@"name"] = @"Jack";NSString *name = dict[@"name"];``` ##8.2 字典转模型的流程 !...声明属性 @property (nonatomic, copy) NSString *name;@property (nonatomic, copy) NSString *icon; // 图像,定义属性时
rowHeight; 设置分区的头视图高度和尾视图高度(当代理方法没有实现时才有效) @property (nonatomic) CGFloat ...sectionHeaderHeight; @property (nonatomic) CGFloat sectionFooterHeight...; @property (nonatomic) CGFloat estimatedSectionFooterHeight; 设置分割线的位置 @property...获取分区数 - (NSInteger)numberOfSections; 根据分区获取行数 - (NSInteger)numberOfRowsInSection:(NSInteger)section;...scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated; 这个函数与上面的非常相似,只是它是将表示图定位到选中的行
类型 : 32 位机器上是 float 类型, 64 位机器上是 double 类型; typedef float CGFloat;// 32-bit typedef double CGFloat;/...) pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{ CGFloat width;...)row inComponent:(NSInteger)component{ //UIAlertView 显示的信息 NSString * message; if(component...UIPickerView 中每个选项的 高度 40 - (CGFloat) pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger...默认 YES, 此时按住 + 或 - 不放, value 值会持续增加 或 减小; -- Continuous : 默认 YES, 此时 交互时会立即发送 value change 事件, NO 时 会等交互结束后才发送
allNumber = weakSelf.fhsrate*[weakNumber.text integerValue]; CGFloat allmoney = [weakSelectDanJia.selectTitle...allNumber = self.fhsrate*[_numberTF.text integerValue]; CGFloat allmoney = [SelectView.selectTitle...所以说使用 NSInteger 更好,会根据32位系统还是64位系统来确定变量的长度,更好的利用系统所提供的最大位数。...iOS中的文件的拷贝、移动、新建、删除、读取等都是 NSFileManager来实现的,而且这个类对象是单例。 8....把JSon的txt文件转 NSDictionary NSString *path = [[NSBundle mainBundle] pathForResource:@"lnglatInformation
2、公交出行方案:QMSBusingRoutePlan,表示从起点到终点的完整出行规划 属性 说明 CGFloat distance 方案的总距离 CGFloat duration...标记该分段的出行方式 CGFloat distance 分段的距离 CGFloat duration 分段的预估时间 CGFloat price 如果是公交或者地铁...*vehicle 交通工具:公交、地铁 NSString *id_ 应该是个标记,没发现作用 CGFloat distance 距离 NSTimeInterval...duration 预计乘坐时间 NSString *title 车名:如333路、软件园通勤车等 NSArray *polyline 途径坐标点 NSInteger station_count..., assign) NSInteger stationCount; // 上车站名称 @property (nonatomic, strong) NSString *startStationName;
: 逻辑混乱,需要完善 - (NSInteger)sumNumber:(NSInteger)firstNumber withNumber:(NSInteger)secondNumber; 四、命名规范...1.变量 变量名必须使用驼峰格式 类,协议使用大驼峰,前缀添加GJR: GJRHomePageViewController.h 对象等局部变量使用小驼峰:...* const GJR_ORDER_TITLE = @"订单"; static const CGFloat GJR_ORDER_IMG_HEIGHT = 50.0f; 不推荐这样写: #define...)width height:(CGFloat)height; 不推荐这样写: - (instancetype)initWithWidth:(CGFloat)width andHeight:(CGFloat...//清除数据 - (NSString *)gjr_...
assign) NSTableView *tableView; //设置列宽度 @property CGFloat width; //设置最小列宽度 @property CGFloat minWidth...; //设置最大列宽度 @property CGFloat maxWidth; //设置类标题 @property (copy) NSString *title; /* 列标题视图 开发者可以对其进行修改...当objectValueForTableColumn方法将每个行具体的数据返回后,会调用cell的setObjectValue方法(因此如果要自定义cell,必须实现这个方法)。...:(NSInteger)startRow toRow:(NSInteger)endRow forString:(NSString *)searchString NS_AVAILABLE_MAC(10_5...)row; /* 调整列宽度 */ - (CGFloat)tableView:(NSTableView *)tableView sizeToFitWidthOfColumn:(NSInteger)column
1、目前支持动态图(GIF)、静态图,未来还会支持视频、缓存、横向等。...; NSString *ext = name.pathExtension; NSString *path = nil; NSArray *exts = ext.length >...self.viewControllers indexOfObject:_currentPage]; [self.pageControl setCurrentPage:currentIndex]; } } 等页面切换完成后才切换底下的...dots #pragma mark ------ changeAlpha ------ - (void)changeAlphaWithRatio:(CGFloat)ratio scrollView:...nextPageAlpha = ratio; CGFloat currentPageAlpha = 1 - ratio; // warning: don't mix up the
、NSString、CGFloat、id、instancetype等。.../NSSize等尺寸相关的 ,还有NSRange、NSIndex等范围相关。...OC中的NSInteger就是对整型的一个封装,64-bit系统上NSInteger对应的是长整形,32-bit系统上对应的是整型。...NSValue主要就是将这些原生的数据封装成对象,方便我们进行存储访问。...、文件、字符串等数据转化为字节流数据,方便数据的封装和流动,比较常见的是NSString/NSImage以及文件数据的封装与传递。
核心思想 实现步骤:方法的返回值是block,block必须有返回值(本身对象),block参数(需要操作的值) 链式编程特点:将多个操作(多行代码)通过点号(.)链接在一起成为一句代码,使代码可读性好...DKUsingblockImplementChainProgramming /** 核心思想 */ //核心的实现步骤:方法的返回值是block,block必须有返回值(本身对象),block参数(需要操作的值) //链式编程特点:将多个操作..., UIColor*, kn_strokeColor); // 倾斜 正值右倾,负值左倾 k_PropertyStatement(assign, NSMutableAttributedString, CGFloat...*, kn_link); // 图文混排等 k_PropertyStatement(strong, NSMutableAttributedString, NSTextAttachment*, kn_attachment...))kn_obliqueness{}; - (NSMutableAttributedString * _Nonnull (^)(CGFloat))kn_obliqueness{ return
description here 修改完的代码: 修改方法有很多种,现给出一种做示例: // .h文件 // 修改完的代码,这是第一种修改方法,后面会给出第二种修改方法 typedef NS_ENUM(NSInteger...建议使用 NS_ENUM 和 NS_OPTIONS 宏来定义枚举类型,参见官方的 Adopting Modern Objective-C 一文: //定义一个枚举 typedef NS_ENUM(NSInteger...age 属性的类型:应避免使用基本类型,建议使用 Foundation 数据类型,对应关系如下: int -> NSInteger unsigned -> NSUInteger float -> CGFloat...: withAge: 应当换为age:,age: 已经足以清晰说明参数的作用,也不建议用 andAge: :通常情况下,即使有类似 withA:withB: 的命名需求,也通常是使用withA:andB...)initWithName:(CGFloat)width andAge:(CGFloat)height; //正确,使用"and"来表示两个相对独立的操作 (BOOL)openFile:(NSString
,因此当tableView超出安全区域时,系统自动会调整SafeAreaInsets值,进而影响adjustedContentInset值 // 有些界面以下使用代理方法来设置,发现并没有生效 - (CGFloat...)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; - (CGFloat)tableView...; } iOS 11适配之跳转App Store评论 在iOS 11之前,为了让用户直接跳到App Store的评论页面,你的代码大概是这样写的: -(void)goToAppStore { NSString...我试了一下,果然如此,顺便看了一下其他家的APP,不少大厂的APP也掉进了这个坑里还没爬出来,比如饿了么,百度外卖等。...经过搜索引擎的帮助,我找到了如下办法: -(void)goToAppStore { NSString *itunesurl = @"itms-apps://itunes.apple.com/cn/app
*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; - (nullable NSString...- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; - (CGFloat...)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; - (CGFloat)tableView...可以想象,如果界面需求发生变化,调整行数或将某个cell的位置移动一下,修改成本是非常大的。...所以解决这个问题,我们需要通过一种方法将所有这些UI逻辑集中起来。 因为接手项目的后续开发者不是看不懂其中的语法或者代码,他有可能看不懂的是其中的逻辑。
; 91 } 92 93 //每一行的数据 94 -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger...109 -(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{ 110...} //返回高度 -(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component...{ return 35.0f; } //返回宽度 -(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger...下面主要就是说一下如何获取年月这样的数据,主要是用到了NSDateComponents 的直接获取一个月前的信息,然后通过将NSCalendar将NSDateComponents转化为日期Date,最后将
除此之外,在开发过程中,我们应该尽量将界面、功能相似的类的代码提取到基类里面,然后各个子类继承自这个基类,实现各自的其他特殊部分。...这里要说明一点,这个绑定策略如何选择,老司机目前也没有搞懂,所以策略这里都沿用了原作者的写法,等老司机搞懂了之后会告诉大家的。...---- -(CGFloat)DW_CalCulateCellWithIdentifier:(NSString *)identifier configuration:(void(^)(id cell))...configuration 最后一个方法: ///根据重用表示取出cell并操作cell后,计算高度 -(CGFloat)DW_CalCulateCellWithIdentifier:(NSString...---- 留给外界的接口 -(CGFloat)DW_CalculateCellWithIdentifier:(NSString *)identifier indexPath:(NSIndexPath *
NSNumber介绍 NSArray\NSDictionary中只能存放OC对象,不能存放int\float\double等基本数据类 如果需要使用将基本数据的值作为对象使用,比如说放进数组或字典中,需要先将基本数据类型包装成...- (NSNumber *)numberWithBool:(BOOL)value; 示例 int age = 10; double number= 5.1; int value = 6; // 将基本数据类型转换为对象类型...Foundation提供了NSValue类将结构体转换为对象,并把它存储在集合中。...now = %@", now); // 获取当前所处的时区 NSTimeZone *zone = [NSTimeZone systemTimeZone]; // 获取当前时区和指定时区的时间差 NSInteger...*time1 = @"2016-06-23 12:18:15"; NSString *time2 = @"2016-06-28 10:10:10"; // 将时间转换为date NSDateFormatter