Tag: swift2

我们如何在整个应用程序中设置iOS 9状态栏的Light内容风格?

我想将Light Content样式应用于整个应用程序。 以下方法在iOS 9中不推荐使用replace方法。 -setStatusBarStyle:animation: 设置状态栏的样式,可select将animation过渡到新样式。 在AppDelegate工作就像: Swift 1.2代码: UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true) 但是当我将我的项目升级到iOS 9 / Swift 2时,他们给我的警告信息是: <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. <Error>: CGContextRestoreGState: invalid context […]

AdMob 7.3.1和Swift 2.0 – 找不到模块

我在Swift 2.0中使用Google AdMob框架时遇到问题。 我第一次使用AdMob,所以我不知道问题出在AdMob或Swift 2.0上。 我已经包含了AdMob框架,并将其导入到我的ViewController中: import GoogleMobileAds 我得到的错误是: 没有这样的模块GoogleMobileAds 桥头也不起作用: #import <GoogleMobileAds/GoogleMobileAds.h> 错误: 找不到GoogleMobileAds / GoogleMobileAds.h文件 我应该如何joinAdMob? 我已经testing了AdMob 6.12.2,并通过桥接头将其包括在内,并且工作正常。 其他用户以前的post没有帮助我 – 这个问题没有解决scheme。

如何获得Alamofire.request()。responseJSON在swift 2中的结果值?

我有一个关于Swift 2的新版本Alamofire的问题 Alamofire.request(.POST, urlString, parameters: parameters as? [String : AnyObject]) .responseJSON { (request, response, result) -> Void in let dico = result as? NSDictionary for (index, value) in dico! { print("index : \(index) value : \(value)") } } 在本节中,我想将结果转换为NSDictionary。 但是当我编译并放置一个断点时,debugging器说dico是零。 如果我使用debugDescription打印结果,它不是零,并包含我所期望的如何投出结果variables?

Swift 2.0中使用故事板的通用控制器

我试图为我的应用程序创build一个GenericListController。 我有一个ProductListController扩展这个扩展UIViewController的通用控制器。 我已经将ProductListController连接到一个故事板并创build了2个sockets,但是我总是收到这个错误: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7c158ca0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key searchBar.' 我收到所有我的网点这个错误,如果我从GenericListController中删除genericsT它的作品。 我想故事板不能加载generics的超级。 我怎样才能使它工作? 我的代码: class GenericListController<T> : UIViewController { var list : [T] = [T]() var filteredlist : [T] = [T]() func getData(tableView : UITableView) { ….. } func setData(list […]

在Swift for iOS中沿着圆形path绘制文本

我正在寻找一些最新的帮助/提示关于如何使用Swift2 for iOS9在圆的边缘绘制简单的单行string。 我看到相当陈旧的例子涉及旧的ObjC片段,而且仅限于OS X 这是甚至可能在自定义的UIView子类的drawRect()方法中的iOS?

Swift – “使用未parsing的标识符”

我在学Swift! 我想在xib上创build主界面。 但有错误“使用未解决的标识符”。 从MainViewController添加代码 import Foundation public class MainViewController : BaseViewController { override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) // TODO: Write your test code here // … } } UPD:(添加图片)

如何使我的应用程序离线数据库?

我在使用RestAPI和保存离线数据时遇到问题。 有没有人对此有最好的想法。 我想从本地数据库中的服务器保存JSON响应,并在没有互联网可用时使用这些数据。 如Firebase实时数据库。

迅速的解包exception没有传播

我已经遇到了这种愚蠢的行为,在强制解包可选不传播。 从文档: 试着用! 访问不存在的可选值会触发运行时错误。 在使用之前,一定要确保一个可选项包含非零值! 强迫 – 打开它的价值。 重现: func foo(bar:String?) throws{ print(bar!); } 和 try foo(nil); 这似乎不符合逻辑或我一致,我无法find任何有关这个问题的文件。 这是由devise?

为栏button项目设置图像和标题?

我目前有一个自定义的导航控制器与栏button项目,只是文本button。 是否可以保留酒吧button项目的标题,但也可以将其设置为图像(图标图像+下面的标题)。 class NavigationController: UINavigationController { var mode: NavigationMode = .Swipe { didSet { self.setButtonAttributes() } } private var leftBarButton: UIBarButtonItem! private var middleBarButton: UIBarButtonItem! private var rightBarButton: UIBarButtonItem! private var rightBarButton2: UIBarButtonItem! override func viewDidLoad() { super.viewDidLoad() } func configureNavigationItem(navigationItem: UINavigationItem) { //Configure the bar buttons text and actions if (self.leftBarButton == nil) { […]

如何将Youtubevideoembedded到我的应用程序中?

我试图为我的Swift应用程序创build一个video播放器,但我不断收到“未parsing标识符AVPlayerViewController”的错误。 我错过了什么? 我是这个初学者,可能要用几十年的时间, 我一直在search互联网,看看如何将Youtubevideoembedded到我的应用中,而没有任何结果。 如果你能指点我的教程,那将是非常棒的! 谢谢!