iOS开发————详解适配iOS10问题

2020-01-18 18:52:46丽君

使用此属性可以给键盘和系统信息,关于用户输入的内容的预期的语义意义。例如,您可以指定一个文本字段,用户填写收到一封电子邮件确认uitextcontenttypeemailaddress。当您提供有关您期望用户在文本输入区域中输入的内容的信息时,系统可以在某些情况下自动选择适当的键盘,并提高键盘修正和主动与其他文本输入机会的整合。

 9.iOS 10 字体随着手机系统字体而改变

当我们手机系统字体改变了之后,那我们App的label也会跟着一起变化,这需要我们写很多代码来进一步处理才能实现,但是iOS 10 提供了这样的属性adjustsFontForContentSizeCategory来设置。因为没有真机,具体实际操作还没去实现,如果理解错误帮忙指正。


UILabel *myLabel = [UILabel new];  /*
  UIFont 的preferredFontForTextStyle: 意思是指定一个样式,并让字体大小符合用户设定的字体大小。
  */
  myLabel.font =[UIFont preferredFontForTextStyle: UIFontTextStyleHeadline]; /*
 Indicates whether the corresponding element should automatically update its font when the device's UIContentSizeCategory is changed.
 For this property to take effect, the element's font must be a font vended using +preferredFontForTextStyle: or +preferredFontForTextStyle:compatibleWithTraitCollection: with a valid UIFontTextStyle.
 */
   //是否更新字体的变化
  myLabel.adjustsFontForContentSizeCategory = YES;

10.iOS 10 UIScrollView新增refreshControl

 ios10,适配问题,适配ios10遇到的问题,ios10开发适配问题

 iOS 10 以后只要是继承UIScrollView那么就支持刷新功能:


@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;

 11.iOS 10 判断系统版本正确姿势

判断系统版本是我们经常用到的,尤其是现在大家都有可能需要适配iOS 10,那么问题就出现了,如下图:

 ios10,适配问题,适配ios10遇到的问题,ios10开发适配问题

我们得到了答案是:


//值为 1 [[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue]

//值为10.000000 [[UIDevice currentDevice] systemVersion].floatValue,

//值为10.0 [[UIDevice currentDevice] systemVersion]

所以说判断系统方法最好还是用后面的两种方法,哦~我忘记说了[[UIDevice currentDevice] systemVersion].floatValue这个方法也是不靠谱的,好像在8.3版本输出的值是8.2,记不清楚了反正是不靠谱的,所以建议大家用[[UIDevice currentDevice] systemVersion]这个方法!