【1】對于數(shù)位比較大的數(shù)字厉亏,要注意使用longlong來聲明伪嫁,避免CPU分配內(nèi)存不夠出現(xiàn)bug哮奇。
本人在時間戳與時間的相互轉(zhuǎn)化的時候遇到此類問題饭耳,導(dǎo)致顯示出來的時間總是不正確串述,謹以此提醒自己和廣大開發(fā)者朋友們。下面列出時間與時間戳之間的相互轉(zhuǎn)化代碼:
【2】 對于整體使用xib或storyboard做UI的項目寞肖,如果需要使用代碼來添加控件纲酗,設(shè)置控件約束時應(yīng)該注意,關(guān)掉translatesAutoresizingMaskIntoConstraints這個屬性新蟆,這個屬性默認是打開的耕姊,打開的情況下該控件不受約束控制。
如下栅葡,reusable 是使用xib添加的view,在此reusable視圖上使用代碼添加一個圖片imageView視圖尤泽。
//顯示圖片
UIImageView * imageView = [reusable viewWithTag:1001];
if (!imageView) {
imageView = [[UIImageView alloc]init];
imageView.tag = 1001;
imageView.backgroundColor = [UIColor clearColor];
[reusable addSubview:imageView];
}
NSLayoutConstraint * imageLead = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:imageView attribute:NSLayoutAttributeLeft multiplier:1 constant:-10];
NSLayoutConstraint *imageCenter = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:imageView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
[NSLayoutConstraint activateConstraints:@[imageLead,imageCenter]];
imageView.translatesAutoresizingMaskIntoConstraints = NO ; //imageView的這個屬性一定要關(guān)掉欣簇,不然imageView不會顯示
NSString * imageName = [self.headers[indexPath.section]objectForKey:@"image"];
imageView.image = [UIImage imageNamed:imageName];
[reusable layoutIfNeeded];