相关疑难解决方法(0)

致命错误:在课堂上使用未实现的初始化程序'init(coder :)'

我决定用Swift语言继续我的剩余项目.当我在storyboard viewcontroller中添加自定义类(.swift类,哪个子类到UIViewcontroller)并加载项目时,应用程序突然崩溃并出现以下错误:

致命错误:在课堂上使用未实现的初始化程序'init(coder :)'

这是一个代码:

import UIKit

class TestViewController: UIViewController {

    init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        // Custom initialization
    }

    override func viewDidLoad() {
        super.viewDidLoad()
              // Do any additional setup after loading the view.
    }

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

    /*
    // #pragma mark - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation …
Run Code Online (Sandbox Code Playgroud)

macos uiviewcontroller ios swift

155
推荐指数
3
解决办法
8万
查看次数

如何在Swift中继承UITableViewController

我想继承UITableViewController,并能够通过调用没有参数的默认初始化程序来实例化它.

class TestViewController: UITableViewController {
    convenience init() {
        self.init(style: UITableViewStyle.Plain)
    }
}
Run Code Online (Sandbox Code Playgroud)

从Xcode 6 Beta 5开始,上面的示例不再有效.

Overriding declaration requires an 'override' keyword
Invalid redeclaration of 'init()'
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift xcode6

40
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×2

swift ×2

macos ×1

uitableview ×1

uiviewcontroller ×1

xcode6 ×1