ios - swift xcode 错误 : Thread 1 signal SIGABRT "instantiated view controller from storyboard but didn' t get a UITableView

标签 ios swift

这个项目的目的是创建一个登录和帐户激活屏幕,可以通过单击按钮在彼此之间移动,这些按钮将激活进出每个屏幕的 segues。

这里是错误:

2016-03-02 18:13:33.979 FinalProjectDavid[7609:406027] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000105e1be65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107b5bdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000105e1bd9d +[NSException raise:format:] + 205
    3   UIKit                               0x0000000106a19af4 -[UITableViewController loadView] + 638
    4   UIKit                               0x00000001067ceb74 -[UIViewController loadViewIfRequired] + 138
    5   UIKit                               0x00000001067d4f4f -[UIViewController __viewWillAppear:] + 120
    6   UIKit                               0x0000000106804e44 -[UINavigationController _startCustomTransition:] + 1203
    7   UIKit                               0x000000010681523f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
    8   UIKit                               0x00000001068163af -[UINavigationController __viewWillLayoutSubviews] + 57
    9   UIKit                               0x00000001069bcff7 -[UILayoutContainerView layoutSubviews] + 248
    10  UIKit                               0x00000001066ef4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
    11  QuartzCore                          0x000000010aba159a -[CALayer layoutSublayers] + 146
    12  QuartzCore                          0x000000010ab95e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    13  QuartzCore                          0x000000010ab95cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    14  QuartzCore                          0x000000010ab8a475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    15  QuartzCore                          0x000000010abb7c0a _ZN2CA11Transaction6commitEv + 486
    16  UIKit                               0x0000000106632f7c _UIApplicationHandleEventQueue + 7329
    17  CoreFoundation                      0x0000000105d47a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x0000000105d3d95c __CFRunLoopDoSources0 + 556
    19  CoreFoundation                      0x0000000105d3ce13 __CFRunLoopRun + 867
    20  CoreFoundation                      0x0000000105d3c828 CFRunLoopRunSpecific + 488
    21  GraphicsServices                    0x000000010a42ead2 GSEventRunModal + 161
    22  UIKit                               0x0000000106638610 UIApplicationMain + 171
    23  FinalProjectDavid                   0x0000000105c32bbd main + 109
    24  libdyld.dylib                       0x000000010866492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

线程1错误截图: enter image description here

Storyboard截图: enter image description here

AppDelegate 类

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> 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 throttle down OpenGL ES frame rates. 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 inactive 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:.
    }


}

View Controller 类

import UIKit

class ViewController: UIViewController {

    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.
    }
    @IBOutlet weak var Label: UILabel!
    @IBOutlet weak var UsernameTextField: UITextField!

    @IBOutlet weak var PasswordTextField: UITextField!

    @IBOutlet weak var SignInButton: UIButton!

    @IBAction func PressedSignInButton(sender: UIButton)
    {
        var usr = "car"
        var pwd = "123"

        if UsernameTextField.text == usr && PasswordTextField.text == pwd
        {

            Label.text = "The credentials were correct."
            UsernameTextField.resignFirstResponder()
            PasswordTextField.resignFirstResponder()
        }
        else
        {
            Label.text = "The crendeitals were not correct."
            UsernameTextField.resignFirstResponder()
            PasswordTextField.resignFirstResponder()

        }

    }




}

创建帐户页面类:

import UIKit

class CreateAccountPage: UITableViewController
{
    @IBOutlet weak var UserNameTextField: UITextField!

    @IBOutlet weak var PasswordTextField: UITextField!

    @IBOutlet weak var EmailAddressTextField: UITextField!

    @IBOutlet weak var ActivateButton: UIButton!
    @IBOutlet weak var ReturnButton: UIButton!

    @IBAction func PressedActivateButton(sender: UIButton)
    {
     var username = UserNameTextField.text
        var password = PasswordTextField.text
        var EmailAddress = EmailAddressTextField.text

        // create the alert
        let alert = UIAlertController(title: "Activated", message: "Your new account is now activated.", preferredStyle: UIAlertControllerStyle.Alert)

        // add an action (button)
        alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default, handler: nil))

        // show the alert
        self.presentViewController(alert, animated: true, completion: nil)



    }

    @IBAction func ReturnButton(sender: UIButton)
    {
    }
    //performSegueWithIdentifier("mySegueID", sender: nil




}

最佳答案

CreateAccountPage 继承自 UITableViewControllerUITableViewController(及其子类)的 view 属性必须有一个 UITableView

您的问题可以通过将 CreateAccountPage 更改为从常规 UIViewController 而不是 UITableViewController 继承来解决。

关于ios - swift xcode 错误 : Thread 1 signal SIGABRT "instantiated view controller from storyboard but didn' t get a UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35760881/

相关文章:

swift - Swift 中的递归枚举

swift - CLBeacon 接近度始终仅返回 .near 和 .far 值,但不返回 .immediate

SwiftUI:检测 Mac 触控板上的手指位置

iphone - NSNotification 未在 View Controller 中接收来自 appDelegate 的信息

ios - Swift - 带 TabBar 的 NavigationBar 不能正常工作

ios - 没有任何内存问题 - 延迟后重复异步调用方法

ios - iOS App Swift 上的 didTapInfoWindowOfMarker

android - Web View 中的 native 登录和应用程序的其余部分

ios - 当我的应用程序进入后台时,我可以在 dispatch_async 中加入一个循环吗?

ios - 录音看起来没问题,但播放却不行