美文网首页
iOS某些实用方法注释

iOS某些实用方法注释

作者: 顺手给我new一个对象 | 来源:发表于2017-05-18 14:51 被阅读60次

一、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 如果参数是小数,则求本身的四舍五入.
ceil 如果参数是小数,则求最小的整数但不小于本身.
floor 如果参数是小数,则求最大的整数但不大于本身.

Example:如何值是3.4的话,则
-- round 3.000000
-- ceil 4.000000
-- floor 3.00000

int abs(int i);                   // 处理int类型的取绝对值
double fabs(double i); //处理double类型的取绝对值
float fabsf(float i);           /处理float类型的取绝对值

二、处理UITableView、UICollectionView在iOS11中出现的暴走问题

查阅发现 iOS11弃用了automaticallyAdjustsScrollViewInsets属性,新增contentInsetAdjustmentBehavior来替代它

关于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是一个枚举类型,值有以下几种:

  • automatic 和scrollableAxes一样,scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.
  • scrollableAxes 自动计算内边距.
  • never不计算内边距
  • always 根据safeAreaInsets 计算内边距

适配:

    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");
    }

相关文章

  • iOS某些实用方法注释

    一、ceilf、ceil、ceill各种取整方式 Example:如何值是3.4的话,则-- round 3.00...

  • iOS 注释规范

    iOS注释规范&&提高注释效率 iOS注释主要分为以下几种:属性注释、方法集注释、方法注释、普通注释(单行注释)。...

  • iOS 注释方法大全 代码块加快捷键注释

    iOS 注释方法大全 代码块加快捷键注释 iOS 注释方法大全 代码块加快捷键注释

  • iOS开发:代码规范

    一、注释规范 iOS注释主要分为以下几种:属性注释、方法集注释、方法注释、普通注释(单行注释)、类注释。 1、属性...

  • iOS编译警告

    iOS编译警告-消除方法参数检查相关的警告 iOS编译警告-消除注释中的警告

  • iOS 简单使用description方法

    简单的说说ios中的description方法,在iOS中description方法是一个非常实用的方法,在调试程...

  • [iOS]获取手机已安装应用列表

    注意此方法是私有API适用于iOS8 ~ iOS11之前, iOS11之后不实用 简单方法 详细内容 在iOS 1...

  • iOS监听某些事件的方法

    iOS监听某些事件的方法 通知(NSNotificationCenter\NSNotification) 任何对象...

  • 解决xcode 8 注释快捷键失效

    iOS xcode 8 注释快捷键单行注释:在方法的地方按 Command+/标注的功能,快捷键是Command ...

  • iOS 事件监听

    iOS监听某些事件的方法 通知(NSNotificationCenter\NSNotification)任何对象之...

网友评论

      本文标题:iOS某些实用方法注释

      本文链接:https://www.haomeiwen.com/subject/ipusxxtx.html