无法使用UITableViewDelegate

时间:2015-01-02 00:55:53

标签: ios swift ios8

我是iOS的新手,如果这是一个基本问题,请耐心等待。我正在关注these tutorials,在第43课中,该人删除了现有的视图控制器并添加了一个新的视图控制器。然后他插入一个表视图(从故事板),命令点击表视图并将dataSource和委托分配给视图控制器。

然后在ViewController.swift文件中添加UITableViewDelegate,使其看起来像

import UIKit

    class ViewController: UIViewController, UITableViewDelegate{

        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
        }

        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }


    }

然后他命令点击UITableViewDelegate来复制这两个函数:

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!

现在!这些是我面临的问题:

1)当我写UITableViewDelegate时,没有自动完成(这表明出现了问题)

2)当我命令点击UITableViewDelegate时,它会显示找不到符号(所以我无法获得上述功能)

请大家欣赏任何帮助。

非常感谢!

1 个答案:

答案 0 :(得分:1)

尝试进入XCode首选项>地点>然后在Derived Data TextField下有一个箭头。点击它。然后删除DerivedData文件夹并重新启动XCode。这可能会修复您的自动完成,因为它由于某种原因不断崩溃。每当自动填充功能对我不起作用时,我只需删除DerivedData,它通常会再次运行。