问题标签 [swift2.1]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
782 浏览

ios - Xcode 6.3.2 转换为最新的 Swift 语法挂起

我升级到 Xcode 6.3.2 并尝试在我的项目上运行“转换为最新的 Swift 语法”,但它挂起。

添加了屏幕截图

“生成预览...”窗口出现并旋转和旋转,但从未完成。

我在另一个项目上尝试了“转换为最新的 Swift 语法”,效果很好。该项目主要是 Objective-C,但有一些 Swift 文件,包括 Watch 扩展。

我已经安装了最新的命令行工具(虽然这真的没有必要,不是吗?),删除了派生数据,清理了项目,重新启动了 Xcode,重新启动了我的计算机,但 Xcode 仍然挂起。

我无法构建我的项目。它达到了它说“编译 Swift 源文件”的地步,并且永远不会走得更远。

关于其他尝试的任何想法,在哪里寻找线索?

0 投票
2 回答
1186 浏览

ios - 检查文本字段是否为空导致 Swift 2 中的错误

我正在尝试检查文本框是否没有价值。

当我这样做时:

我收到以下错误 在此处输入图像描述

我尝试添加“?” 在“.isEmpty”之前,但错误不会消失 在此处输入图像描述

有任何想法吗?

0 投票
2 回答
162 浏览

swift - 为什么将 NSString 编码常量实现为变量而不是枚举?

为什么编码常量实现为只读变量而不是 Foundation 中的枚举?

0 投票
1 回答
339 浏览

swift2.1 - Swift2.1 调用可以抛出但没有标记try Error

我的代码在 swift 2.0 中运行,但是当我在 swift 2.1 上更新代码时,它的返回错误“调用可以抛出但未标有尝试”请给我解决方案这是我的代码,我已将这一行放在那里,我在行中出现错误“ /****这里是错误****/"

0 投票
1 回答
136338 浏览

ios - 具有透明背景的 Swift 模态视图控制器

我知道这个话题很受欢迎,但我对编程语言有点挑剔,事实是我仍然不明白我把代码放在哪里。好吧,我会告诉整个案例:

在此处输入图像描述

我试图让模态 Swift 与普通的有点不同:通过单击一个按钮,ViewController 在屏幕上显示(按照模态类型),但具有透明背景。只会显示带有标签的蓝色视图。当这个 ViewController 呈现时,它是透明背景,但一旦完成过渡,它就会保持黑色背景。已经停用了不透明选项,并测试了一些选项,但没有进行此故障排除。

有些可以帮助我吗?

该视频是在模拟器中对案例的测试 ( https://www.youtube.com/watch?v=wT8Uwmq9yqY )。

我从 swift 开始,我仍然对如何在 Xcode 中编程感到迷茫,我阅读了一个问题的答案,其中包含以下代码来解决这个问题:

我把这段代码放在哪里?

0 投票
1 回答
608 浏览

ios - viewWillTransitionToSize causes non-rotating view controller to resize and reposition

A lot of people have discussed techniques for mimicking the native iOS camera app (where the UI elements pivot in-place as the device rotates). I actually asked a question about it before here. Most people have you lock the orientation of the UI, but then force a transformation on just the elements that you want to pivot. This works, but the elements don't pivot with the smooth animations you see in the native iOS app and it leads some issues. Specifically, part of my interface allows users to share without leaving this interface, but when the sharing view gets rotated, it comes out off-center. So I wanted to find a different way to do this.

I found a link to Apple's AVCam sample, which got me off to a start here. I'm new to this stuff, but I managed to convert it from Obj-C to Swift already. Below is the key element of what I'm currently using:

I then have separate view controllers for icons that do the same transformation in the opposite direction. The icons actually pivot in place properly now (with smooth animations and everything) and the camera preview stays properly oriented.

The problem is, the non-rotating view gets resized and everything gets misplaced when I rotate the device from portrait to landscape or vice-versa. How do I fix that?

0 投票
1 回答
1358 浏览

macos - 如何使用 XPath 和 Swift 2.0 解析 html?

我正在尝试从网站解析一些数据,但我无法让它工作。

我尝试了 NDHpple、TFHpple、Kanna 所有这些都没有成功。

我想解析:

我使用 Firebug 得到的 XPath 是:

现在我正在使用 Kanna,我的代码是这样的:

那么,任何人都可以帮助我吗?

0 投票
1 回答
859 浏览

parse-platform - “试图用一个新的、未得救的孩子来保存一个对象。” 快速解析

这是我的代码:

这真的很奇怪,因为我有相同的代码模板来注册不同的角色并且它可以正常工作。它一直在扔

我不明白为什么它会引发错误。

添加信息:当我点击注册按钮时,它会转到 tableviewcontroller,我尝试删除 segue 并注册了用户。似乎错误在我的 tableviewconller 中。这是里面的代码。

编辑2:这一行抛出错误

0 投票
2 回答
732 浏览

ios - UICollectionView 单元格绘图问题迅速

在我的项目中,我有uicolelctionview自定义单元格。在collectionView:CellForItemAtIndexPath我得到自定义单元格

并添加此代码

我希望得到这种类型的视图:

在此处输入图像描述

但一些细胞看起来像这样:

在此处输入图像描述

我必须 reloatData 才能获得当前的单元格视图。仍然无法理解为什么我会得到这个错误

0 投票
1 回答
155 浏览

parse-platform - 使用 swift2 从解析中获取总帖子

每次打开应用程序时,它都会返回 6 行,即使我用 1 个帖子创建了一个新用户,它也会返回 6 行。另外,当我拉刷新数据保持不变时,我必须再次重新打开应用程序才能看到添加的新数据。这是我下面的代码,

这是内部单元格