因此,我一直在關注在線Swift課程,並創建一個表視圖。我幾乎從教程中複製了所有代碼,只做了一些調整(因爲課程是用老版本的swift教的,但我使用的是swift 3)。根據教程,我應該得到一個顯示名稱的4行表格視圖,但我得到的是一個「信號SIGABRT」錯誤。並沒有具體指出錯誤。連接插座「數據源」和「委託」後出現錯誤「線程1:信號SIGABRT」
這裏有什麼問題?如果我沒有連接「數據源」插座,我可以運行模擬器,但不會顯示任何問題,但我不會顯示名稱。但是,如果我做連接,我甚至不能運行模擬器。我真的希望我已經明確提出了這個問題,並且足夠讀者友好!
import UIKit
class ViewController: UIViewController, UITableViewDelegate{
var cellContent = ["xiaohong","xiaohua", "xiaogang" ,"xiaoxiao"]
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
public func tableView(_tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cellContent.count
}
public func tableView(_tableView: UITableView, cellForRowAtindexPath indexPath:NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default,reuseIdentifier:"Cell")
cell.textLabel?.text = cellContent[indexPath.row]
return cell }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
爲了使它更清晰,我想在這裏粘貼錯誤信息!
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:.
}
}
非常感謝您提前!
如果您可以創建項目的ZIP文件並將其託管在WeTransfer或某些此類服務上,我認爲幫助您更容易。 –
它現在在Wetransfer上,鏈接是https://wetransfer.com/downloads/b7321f3dadcd688228715bba053d159920170101114400/4a12c5 – Frostless