小编Ark*_*yan的帖子

如何在Swift 3中将文档目录中的图像显示到UIImageView?

下面的Swift 2示例给出了以下错误:

String类型的值没有成员'stringByAppendingPathComponent'

错误的屏幕截图

我需要为Swift 3更改什么?

swift3

6
推荐指数
1
解决办法
4863
查看次数

Swift 3 NSFileManager Xcode 8错误:已重命名为FileManager

试图在Swift 3中获取默认文档目录,但表示已将其重命名为FileManager.如果更新到FileManager然后得到错误:无法调用非函数类型FileManager的值

Xcode 8. Swift 3 Beta 4.

使用FMDB Swift指令中的这一行代码:

let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
Run Code Online (Sandbox Code Playgroud)

swift3

4
推荐指数
1
解决办法
6661
查看次数

swift 3错误:不符合协议'UITableViewDataSource'

使用自定义swift类(不是主ViewController)

码:

import Foundation

class Myclass: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet var tableView: UITableView!

    var items: [String] = ["Item1", "Item2", "Item3"]

    override func viewDidLoad() {
        self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "td")
    }

     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.items.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell:UITableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "td")! as UITableViewCell
        cell.textLabel?.text = self.items[indexPath.row]
        return cell
    }

    func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
        print("You selected cell #\(indexPath.row)!")
    }
}
Run Code Online (Sandbox Code Playgroud)

uitableview

3
推荐指数
1
解决办法
6080
查看次数

标签 统计

swift3 ×2

uitableview ×1