一遗锣、ceilf货裹、ceil、ceill各種取整方式
extern float ceilf(float);
extern double ceil(double);
extern long double ceill(long double);
extern float floorf(float);
extern double floor(double);
extern long double floorl(longdouble);
extern float roundf(float);
extern double round(double);
extern long double roundl(long double);
round 如果參數(shù)是小數(shù)精偿,則求本身的四舍五入.
ceil 如果參數(shù)是小數(shù)弧圆,則求最小的整數(shù)但不小于本身.
floor 如果參數(shù)是小數(shù),則求最大的整數(shù)但不大于本身.
Example:如何值是3.4的話笔咽,則
-- round 3.000000
-- ceil 4.000000
-- floor 3.00000
int abs(int i); // 處理int類(lèi)型的取絕對(duì)值
double fabs(double i); //處理double類(lèi)型的取絕對(duì)值
float fabsf(float i); /處理float類(lèi)型的取絕對(duì)值
二搔预、處理UITableView、UICollectionView在iOS11中出現(xiàn)的暴走問(wèn)題
查閱發(fā)現(xiàn) iOS11棄用了automaticallyAdjustsScrollViewInsets屬性叶组,新增contentInsetAdjustmentBehavior來(lái)替代它
關(guān)于contentInsetAdjustmentBehavior:
typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
UIScrollViewContentInsetAdjustmentAutomatic, // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable
UIScrollViewContentInsetAdjustmentScrollableAxes, // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES)
UIScrollViewContentInsetAdjustmentNever, // contentInset is not adjusted
UIScrollViewContentInsetAdjustmentAlways, // contentInset is always adjusted by the scroll view's safeAreaInsets
} API_AVAILABLE(ios(11.0),tvos(11.0));
UIScrollViewContentInsetAdjustmentBehavior是一個(gè)枚舉類(lèi)型,值有以下幾種:
- automatic 和scrollableAxes一樣,scrollView會(huì)自動(dòng)計(jì)算和適應(yīng)頂部和底部的內(nèi)邊距并且在scrollView 不可滾動(dòng)時(shí),也會(huì)設(shè)置內(nèi)邊距.
- scrollableAxes 自動(dòng)計(jì)算內(nèi)邊距.
- never不計(jì)算內(nèi)邊距
- always 根據(jù)safeAreaInsets 計(jì)算內(nèi)邊距
適配:
if (@available(iOS 11.0, *)) {
NSLog(@"iOS11");
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
self.tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
} else {
NSLog(@"非iOS11");
}