35day 新浪微博(CELL转发)

来源:互联网 发布:淘宝ipad客户端下载 编辑:程序博客网 时间:2024/05/16 18:49

cell 与导航栏的间距设置

/** 方法一*//** 目的 : 让第一个cell与导航栏有固定的间距*/- (void)setFrame:(CGRect)frame{    frame.origin.y += HWStatusCellBorderW;    [super setFrame:frame];}/** 方法二*/- (void)viewDidLoad {    [super viewDidLoad];//    self.tableView.contentInset = UIEdgeInsetsMake(HWStatusCellBorderW, 0, 0, 0);}

图片加载使用的策略

[UIImage imageWithContentsOfFile:]//加载图片不会有缓存,适合加载大的图片,一次性的图片        [UIImage imageNamed:];//加载图片有缓存,适合加载小的图片,且实用频率高的图片1、iOS6、7 的适配:大的资源文件最好放置于Supporting Files 目录由于在ISO7 之后,会对Assets.xcassets中的图片进行压缩 放置于Assets.car 中,因此 [UIImage imageWithContentsOfFile:] 使用该方法,加载图片时,在[NSBundle mainBundle]pathForResource: ofType:  是找不到文件的。所以 大的资源文件最好放置于Supporting Files 目录。

tableView 背景色的设置

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath{    cell.contentView.backgroundColor = HWColor(241, 248, 255);}/** 方法2 */1. self.tableView.backgroundColor = HWColor(241, 248, 255);2.- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];    if (self) {        self.backgroundColor = [UIColor clearColor];    }}

获取图片的颜色

       //        [tmpView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"timeline_card_bottom_background_highlighted"]]];获取图片的颜色

其他

debug 过程,LLDB的常用命令

po (print object ) 输出对象p (int) 用于输出基本类型expr(expression) 动态执行指定表达式: //打印返回报文 expression ((NSString*)[[NSString alloc] initWithData:request.responseData encoding:4] ) call 调用bt 打印调用的堆栈fr v -R 打印未加工的信息

时间格式的处理 HWCreatedAtTool.h

- (NSDate*) dateFromString:(NSString*)stringTime dateformatter:(NSString*)dateformatter localeIdentifier:(NSString*)localeIdentifier {    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];#warning  真机调试,转换时间 需要设置 NSLocale    NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];//zh_CN  en_US en_GB    [formatter setLocale:usLocale];    formatter.dateFormat = dateformatter;    return  [formatter dateFromString:stringTime];}- (NSString*) stringFromDate:(NSDate*)date dateformatter:(NSString*)dateformatter localeIdentifier:(NSString*)localeIdentifier {    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];#warning  真机调试,转换时间 需要设置 NSLocale    NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];//zh_CN  en_US en_GB    [formatter setLocale:usLocale];    formatter.dateFormat = dateformatter;    return  [formatter stringFromDate:date];}

日历的使用(两个时间的比较NSDateComponents)

/** // 处理今年的时间 */- (NSString*)setupDateInThisYear:(NSDate*)tmpDate{    NSCalendarUnit calendarUnit = NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute;    NSDateComponents *dateComponents = [self dateComponentsWithFromDate:tmpDate toDate:[NSDate date] calendarUnit:calendarUnit];    if ([self isToday:dateComponents]) {        /**1》一天之内的时间处理*/        return [self setupTodayTime:dateComponents];    }else if ([self isYesterDay:dateComponents]){        /*2》25-48小时后的时间处理(24小时之后)         yesterday HH:mm  yesterday 17:30  两天之内 (48小时之内)25-48小时之内*/        return [NSString stringWithFormat:@"yesterday %@",[self stringFromDate:tmpDate dateformatter:@"HH:mm" localeIdentifier:@"en_US"]];    }else{        /*3》48小时后的时间处理(其它时间)         MM-dd HH:mm  09-18 17:30      48小时之后*/        return [self stringFromDate:tmpDate dateformatter:@"MM-dd HH:mm" localeIdentifier:@"en_US"];    }}
原创粉丝点击