iOS 开发的一些小知识点

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/blog_DreamFly/article/details/79401944

有些知识点很简单, 写下这些作为备忘,好记性不如烂笔头,持续更新中…

  • Xcode ATS(App Transport Security的简称)设置
    在plist文件中新建类型为Dictionary,key为App Transport Security Settings的键,
    在其节点下添加类型为Boolean key为 Allow Arbitrary Loads 值为YES的键值对.
    ATS

  • 设置相机中文环境(打开相机拍照默认是英文)
    项目工程-> TARGETS ->Info ->Custom iOS Target Properties,
    寻找key值为Localization native development region的一栏修改为China.
    相机中文环境

  • Xcode 模拟器中输入中文
    打开工程项目,command + shift + h : 回到home页;
    Settings->General->Language&Region->Other Languages -> Chinese, Simplified(简体中文)-> Done - > Change to Chinese, Simplified

  • 修改UISearchBar的placeholder的字体、字体颜色

     UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];  
     [searchField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
     [searchField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    
  • Xcode9新建工程运行显示不全屏解决办法
    在info.plist文件里配置key为Launch screen interface file base name
    value为LaunchImage的string。
    屏幕

  • 去掉无参block的xcode警告
    定义没有参数的block typedef void (^Block)();
    xcode会有“This block declaration not a prototype”的警告,去掉xcode警告的解决方法:
    (1).typedef void (^Block)(void);
    (2).typedef void (^Block)(id _Nullable ,...);

  • **setValue 和 setObject 的区别 **
    (1). setObject:forkey方法NSMutabledictionary特有的
    (2). setValue:forKey方法是KVC(键-值编码)的主要方法
    (3). setObject:forkey:中value不能为 nil,key可以是任何类型
    (4). setValue:forKey:中value可以是nil,当value为nil的时候,会自动调用setValue:forUndefinedKey:方法
    (5). setValue:forKey:中key的参数只能是NSString类型

  • Pods管理三方框架,去掉xcode警告
    如ReactiveObjC:在podfile文件中编辑
    pod ‘ReactiveObjC’, ‘~> 3.1.0’,:inhibit_warnings => true # RAC

  • TableView或者WebView整体上移
    self.edgesForExtendedLayout = UIRectEdgeNone;
    适用于不同系统版本代码更迭出现状况时使用。

  • Xcode10 #import 不提示头文件
    Xcode -> File -> Workspace Settings -> Build System -> Legacy Build System
    在这里插入图片描述

    扫描二维码关注公众号,回复: 3758152 查看本文章

    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/blog_DreamFly/article/details/79401944