2017-03-18 10 views
1

ViewControllerの内部にUITableViewを作成したいとき。 私はそれがうまくいったチュートリアルと全く同じように作ったが、AppDelegate.swiftのclass AppDelegate: UIResponder, UIApplicationDelegate {にこのエラー "スレッド1シグナルSIGABRT"がある。 私は最近、前にすべてのコードでこの質問をしましたが、すべての答えには、より多くの情報が必要だと述べました。スレッド1信号SIGABRT Xcodeのエラー[Swift]

私はXcodeプロジェクト全体を新しくし、Screeniumで撮影しました。 ビデオはこちら(10分53メガバイト)https://workupload.com/file/24NNW68です。 パスワードに与える必要があります次に「video.mov」の情報がある

ThePassword。下の(青色)ダウンロードをクリックすると、広告主様が広告を表示します。動画を見たくない人のために

(私の声は少し高いですので、私は、14歳のとき、私はそれを作った:

AppDelegate.swift: 

import UIKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     // Override point for customization after application launch. 
     return true 
    } 

    func applicationWillResignActive(_ application: UIApplication) { 
     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
     // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
    } 

    func applicationDidEnterBackground(_ application: UIApplication) { 
     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
    } 

    func applicationWillEnterForeground(_ application: UIApplication) { 
     // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
    } 

    func applicationDidBecomeActive(_ application: UIApplication) { 
     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
    } 

    func applicationWillTerminate(_ application: UIApplication) { 
     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
    } 


} 

ViewController.swift:ここでは完全なコードがあります

import UIKit 

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 

    @IBOutlet weak var tableView: UITableView! 
    var Label1multi = ["TableView","Alarm Clock","Green","Book"] 
    var Label2multi = ["Pen", "1 Euro","Red","Mobile Phone"] 
    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. 
    } 

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return 4 
    } 

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell 
     cell.Label1.text = Label1multi[indexPath.row] 
     cell.Label2.text = Label2multi[indexPath.row] 
     return cell 
    } 

} 

THISTableViewCell.swift:

import UIKit 

class THISTableViewCell: UITableViewCell { 

    @IBOutlet weak var Label1: UILabel! 
    @IBOutlet weak var Label2: UILabel! 

    override func awakeFromNib() { 
     super.awakeFromNib() 
     // Initialization code 
    } 

    override func setSelected(_ selected: Bool, animated: Bool) { 
     super.setSelected(selected, animated: animated) 

     // Configure the view for the selected state 
    } 

} 

しかし、私は失敗を見つけた:私はアウトレットTableViを削除しますew - DataSource私はエラーは表示されませんが、私はTableViewで空のセルを取得します。

+0

エラーは 'AppDelegate'とは関係ありません。テーブルビューアウトレットはInterface Builderで接続されていない可能性があります。または、カスタムテーブルビューセルのクラスがカスタムクラスに設定されていません。忘れないでください** **感嘆符はクラッシュを引き起こす可能性があります**。 – vadian

+0

@vadianあなたは(Passwortは()「」さんwithouth「ThePassword」である)ビデオhttps://workupload.com/file/24NNW68を見ると、私が間違ってやっていることを教えてもらえますか? – Korne127

+0

私はあなたに言った:アウトレットの1つがInterface Builderで接続されていない。それを確認してください。 – vadian

答えて

0

私はあなたのビデオを見ました。間違いは小さいと思います。属性インスペクタでカスタムセルの再利用識別子を「セル」に設定する必要があります。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell 
    cell.Label1.text = Label1multi[indexPath.row] 
    cell.Label2.text = Label2multi[indexPath.row] 
    return cell 
} 

main.storyboardでセルを選択し、属性インスペクタを選択します。 「識別子」ボックスに「セル」と入力します。

+0

スーパー、それは動作します!どうもありがとうございました! – Korne127

関連する問題