Tag: swift2

将Xcode 7.3.1项目升级到Xcode 8.0

我想将我的Xcode 7.3.1项目升级到Xcode 8.我的项目是在Xcode 7中用swift 2.2编写的,但现在我想用swift 3.0升级到Xcode 8。 我的项目包含一些pod文件库,同时升级到Xcode 8,我面临着很多的警告和错误。 与故事板相关的警告已解决,但pod文件中的错误未解决。 Xcode告诉我把swift语法转换成最新的语法,所以我做到了。 Swift语法错误显示在pod文件中。 我正在尝试解决pod文件的swift语法错误,然后Xcode告诉我解开pod文件,我做了,但然后豆荚不工作。 有谁知道如何解决pod文件错误? 或者如何将整个Xcode 7.x项目转换为Xcode 8?

sendSynchronousRequest在ios 9中已弃用

Xcode说sendSynchronousRequest已经被弃用了。 我应该如何replace它? let postData:NSData = post.dataUsingEncoding(NSASCIIStringEncoding)! let postLength:NSString = String( postData.length ) let request:NSMutableURLRequest = NSMutableURLRequest(URL: url) request.HTTPMethod = "POST" request.HTTPBody = postData request.setValue(postLength as String, forHTTPHeaderField: "Content-Length") request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.setValue("application/json", forHTTPHeaderField: "Accept") var response: NSURLResponse? var urlData: NSData? do { urlData = try NSURLConnection.sendSynchronousRequest(request, returningResponse:&response) } catch _ as NSError { urlData = […]

如何在不使用第三方库的情况下在swift2中下载页面?

我正试图在应用程序中显示下载的HTML页面。 请解释最简单的方法,而不使用任何第三方库。 干杯,

如何在Swift 2.0中使用完成button做数字键盘?

我已经用完成button尝试了很多数字键盘,但在SWIFT 2.0中找不到正确的答案。

如何在swift 2中更改date格式化程序?

我知道如何将date转换为string和stringdate的基本知识。 但是我面临以下问题: dateAsString = "2016/12/31" 我想将这个string转换为 date和string格式,位置更改为12/31/2016 。 请帮忙

SWrevealviewcontroller:切实地从左向右切换滑出菜单的方向

我在有两种语言(英语和阿拉伯语)的应用程序上工作,我已经使用左侧的“SWrevealviewcontroller”库实现了滑出菜单,我想在语言切换(阿拉伯语)上切换滑出菜单到右侧窗体左侧,并切换再次回到从右到左的英文。 我们如何将其归档? 谢谢

无法将jsonArray元素转换为整数

do{ let resultJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) let arrayJSON = resultJSON as! NSArray let success:NSInteger = arrayJSON["success"] as! NSInteger if (success == 1 ) …. json的数据是从服务器的响应,我试图将其转换为整数,但我得到的对话错误。

由于信号故障,命令失败 – Swift 2.2 Xcode 7.3

我正在更新所有我的swift更新到xcode 7.3的过程中,在过程中,我得到了一些错误ambiguous use of subscript swift错误,我相信这个错误也导致信号故障。 有问题的代码: override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var arry:NSArray = Array(self.participants) arry = arry.sort { item1, item2 in // ambiguous use of subscript swift error for both these lines let date1 = item1["fullName"] as String let date2 = item2["fullName"] as String return date1 > date2 } 编辑 […]

在新的UIView中获取点击UITableViewCell的对象?

从UITableViewCell中的单元格向新的视图传递参数数据的正确方法是什么? 我从我的UITableViewCell中的原型单元格中指定了一个segue,它将它链接到一个新的UIVIew并设置为show (aka push) 。 新的UIView显示,但我不知道如何告诉UIView选定的部分/行或告诉它关于与该select相关联的对象。 我的代码的删节版本如下所示: class MyTableViewController : UITableViewController { // other code omitted override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let files = filesByDate[filesByDateKeys![indexPath.section]] self.selectedFile = files![indexPath.row] } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if (segue.identifier == "SegueToFileDetails") { let destinationViewController = segue.destinationViewController as! FileDetailsViewController destinationViewController.file = self.selectedFile } } […]

如何在UITableViewCell中点击单元格的button,而不用动作单元格的继续

我的自定义单元格有2个button,每个自定义单元格也执行一个segue。 seguefunction正常,问题来自我的button从未被解雇的事实。 如果我点击他们然后赛格被解雇,但不是button。 如何克服这一点? 这里是如何定义button的动作的代码: 在表格视图控制器中 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(CCELL.WISHCELL, forIndexPath: indexPath) as! WishCell let row = indexPath.row let product = products.elements[row] // Setup the 2 cell buttons cell.removeButton.tag = indexPath.row cell.addToCartButton.tag = indexPath.row cell.removeButton.addTarget(self, action: "removeFromWishList:", forControlEvents: .TouchUpInside) cell.addToCartButton.addTarget(self, action: "addToCart", forControlEvents: .TouchUpInside) select器的目标函数是有效的,我没有错误。 […]