------------1. //让cell选中效果松开消失
[tableView deselectRowAtIndexPath :indexPath animated : YES ]
------------2. //这只这个防止TextView上边那段空白,Scrllview的原因,因为nav导致的空白
self.automaticallyAdjustsScrollViewInsets = NO;
------------3. // 以下两个方法可以保证CZSettingController创建出来肯定是Grouped类型的表格
- (id)init
{
return [super initWithStyle:UITableViewStyleGrouped];
}
- (id)initWithStyle:(UITableViewStyle)style
{
return [super initWithStyle:UITableViewStyleGrouped];
}
------------4. //修改状态栏背景
修改info文件 添加一句: View controller-basedstatus bar appearance = NO
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
------------5. // 二进制
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/json",@"text/javascript", @"text/html", nil];
------------6. //沙盒目录
NSString *path = NSHomeDirectory();
NSLog(@"NSHomeDirectory:%@",path);
------------7. // 获得资源中本地字符串
#define LOCALIZED_STRING(name)NSLocalizedStringFromTable(name, @"infoPlist", nil)
------------8. // 自定义Log
#ifdef DEBUG // 如果是调试阶段, 将DDLog替换为NSLog
#define DDLog(...)NSLog(__VA_ARGS__)
#else // 如果是发布阶段, 将DDLog替换为空白
#define DDLog(...)
#endif
------------9. // 快速创建颜色
#define DDColor(r, g, b, a)[UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0alpha:(a)/255.0];
// 随机颜色
#define DDRandomColorDDColor(arc4random_uniform(255), arc4random_uniform(255),arc4random_uniform(255), arc4random_uniform(255))
------------10. //SVPullToRefresh修改 .m文件197行
// CGFloat scrollOffsetThreshold =scrollViewContentHeight-self.scrollView.bounds.size.height;
//这句话代替上句可避免首页刷新bug
CGFloatscrollOffsetThreshold =MAX(scrollViewContentHeight-self.scrollView.bounds.size.height,0);
------------11. //数据间转换
1.NSString相关
1.NSDictionary转换成NSString:
NSArray *array = [NSArray arrayWithObjects:@“hello”,@“world”,nil];
NSString *str = [array componentsJoinedByString@“”];
2.char* 转换成NSString
NSString *dataStr = [NSString stringWithCSting:(char *)encoding:NSUTF8StringEncoding];
3.NSData转换成NSString
NSString *str = [[NSString alloc] initWithData:dataencoding:NSUTF8StingEncoding];
2.NSDictionary相关
1.NSDictionary转成josn字符串
-(NSString *)dictionaryToJson:(NSDictionary *)dic
{
NSError *parseError = nil;
NSData *jsonData = [NSJsonSerialization dataWithJSONObject:dicoptions:NSJSONWritingPrettyPrinted error:&parseError];
return [[NSSting alloc] initWithData:jsonDataencoding:NSUTF8StringEncoding];
}
2.NSString转换成NSDictionary
NSDictionary *dic = [dicStr JSONValue];
3.NSData相关
1.Byte转NSData
NSData *data = [NSData dataWithBytes:byteslength:Strlen(packet->getPayload())];
------------12. 判断当前型号方法
//iPhone 4尺寸 #define iPhone4 ([UIScreeninstancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen] currentMode].size) : NO)
//iPhone 5尺寸 #define iPhone5 ([UIScreeninstancesRespondToSelector:@selector(currentMode)] ?CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen]currentMode].size) : NO)
//iPhone 6 和 6+尺寸 #define iPhone6 ([UIScreeninstancesRespondToSelector:@selector(currentMode)] ?(CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen]currentMode].size) || CGSizeEqualToSize(CGSizeMake(1920,1080), [[UIScreenmainScreen] currentMode].size)) : NO)