xcode7.1新建项目等问题

一、LaunchImage不显示

  解决办法:

  1.在Assets.xcassets新建LaunchImage并加入不同屏幕的launchImage

  2.点击项目名,点击TARGETS,选择General,找到App Icons and Launch Images,1)在Launch Images Source 中选中LaunchImage;2)在Launch Screen File 中清除内容,使其为空

二、tabBarItem设置选中的图片,全让颜色填充了

  解决办法:

1.调用:

  @available(iOS 7.0, *)

  public func imageWithRenderingMode(renderingMode: UIImageRenderingMode) -> UIImage

如:

  tabBarItem.image = UIImage(named: "tab_nor")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

  tabBarItem.selectedImage = UIImage(named: "tab_sel")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

三、statusBar的颜色,启动时隐藏statusBar,启动后显示

  1.在info.plist中添加 Status bar is initially hidden 设为YES(启动时不显示statusBar)

  2.在AppDelegate中调用application.statusBarHidden = false

  3.在info.plist中添加 View controller-based status bar appearance 设为NO(不显示基本的状态栏)

  4.application.statusBarStyle = UIStatusBarStyle.LightContent(将状态栏风格设为亮色,即白色)

四、Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport Security policy requir

  iOS9引入了新特性App Transport Security (ATS)。详情:App Transport Security (ATS)新特性要求App内访问的网络必须使用HTTPS协议。

  若要使用HTTP协议,解决办法:

  1.在Info.plist中添加NSAppTransportSecurity类型Dictionary。
  2.在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

五、Swift和OC混编

  1.Swift项目中,如果加入OC文件,系统会弹出Would you like to configure an Objective-C bridging header?的选项,选择yes,Xocde就会在新建OC文件的同时帮我们新建一个 xxx-Bridging-Header.h 文件,xxx是你的项目名称(Product Module),在这个文件里加入OC的头文件,即可在swift中使用OC

  2.如果想自己新建 xxx-Bridging-Header.h 文件,步骤是:File > New > File > (iOS or OS X) > Source > Header File,切记,名字 一定要 是 项目工程名-Bridging-Header,然后在项目的 Build Settings > Swift Compiler选项里有这个Bridging Header,设置路径为 项目名/项目名-Bridging-Header.h

  3.而要在OC中调用swift代码,只需引用头文件  #import "项目名-Swift.h" (这个是系统自动生成的头文件定义了项目中所有的Swift文件)

原文地址:https://www.cnblogs.com/hcsaaron/p/4936554.html