Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's New in iOS #95

Open
ShannonChenCHN opened this issue Oct 10, 2017 · 9 comments
Open

What's New in iOS #95

ShannonChenCHN opened this issue Oct 10, 2017 · 9 comments

Comments

@ShannonChenCHN
Copy link
Owner

ShannonChenCHN commented Oct 10, 2017

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Oct 12, 2017

iOS 11 适配

1. 导航栏大标题的展示

先设置 UINavigationBarprefersLargeTitles 属性和 largeTitleTextAttributes 属性:

if (@available(iOS 11.0, *)) {
      self.navigationBar.prefersLargeTitles = YES;
      self.navigationBar.largeTitleTextAttributes = @{NSForegroundColorAttributeName : kNavigationBarTitleColor};
} else {
      // Fallback on earlier versions
}

然后再根据需要在 UIViewController 中设置:

if (@available(iOS 11.0, *)) {
        if ([self preferredDisplayLargeTitle]) {
            self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
         } else {
            self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
        }
    } else {
        // Fallback on earlier versions
    }

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Oct 12, 2017

iOS 11 适配

2. UIViewControllerautomaticallyAdjustsScrollViewInsets 属性

iOS 11 中 UIViewControllerautomaticallyAdjustsScrollViewInsets 属性被废弃了,导致了这两个页面出现了问题:

iOS11 中系统不再自动调整 UIViewControllerUIScrollViewcontentInset 属性了,而是给 UIScrollView 新增了一个 adjustedContentInset 属性和 contentInsetAdjustmentBehavior 属性。

解决办法:

if (@available(iOS 11.0, *)) {
    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
    self.automaticallyAdjustsScrollViewInsets = NO;
}

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Oct 12, 2017

iOS 11 适配

3. 导航栏高度的变化

原来是 64pt,现在是 44 pt

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Oct 12, 2017

iOS 11 适配

4. UITableViewUITableViewCell相关

  • iOS 11 中会默认启用 Self-Sizing
  • iOS 11 中的 UITableViewCell,在 separatorInset 属性上,新增了 separatorInsetReference 属性
  • Safe Area 对 UITableView 的影响
    • separatorInset 被自动地关联到 safe area insets,因此,默认情况下,表视图的整个内容避免了其根视图控制器的安全区域的插入。
    • UITableviewCell 和 UITableViewHeaderFooterView的 content view 在安全区域内;因此你应该始终在 content view 中使用add-subviews操作。
    • 所有的 headers 和 footers 都应该使用UITableViewHeaderFooterView,包括 table headers 和 footers、section headers 和 footers。
  • UITableView 的滑动手势操作功能的扩展
    • 可以给操作按钮添加图片
    • 新增了两个代理方法,可以通过 UIContextualAction 来自定义动作,

@ShannonChenCHN
Copy link
Owner Author

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Aug 27, 2018

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Oct 9, 2018

iOS 12 新特性

1. 自动生成强密码和自动填充验证码/密码

@ShannonChenCHN
Copy link
Owner Author

ShannonChenCHN commented Sep 23, 2019

iOS 系统版本兼容的问题

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  • The new API will crash if we call it on iOS 7
  • The new API won't compile if we build it using the iOS 7 SDK
  • The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

两种状态:

  • 编译时(取决于 IDE 构建环境的 SDK)
  • 运行时(取决于运行的设备)

几个宏/注解:

  • __IPHONE_OS_VERSION_MAX_ALLOWED(定义在Foundation/NSObjecRuntime.h 文件中)
  • __IPHONE_OS_VERSION_MIN_REQUIRED
  • __IPHONE_11_0(usr/include/Available.h文件中,一般写成数字 110000)
  • @available

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant