此项目的目的是创建一个登录和帐户激活屏幕,可以通过单击按钮来相互移动,这些按钮将激活移动到每个屏幕的片段。
这是错误:
nsqd
线程1错误截图: enter image description here
故事板截图: enter image description here
AppDelegate类
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)
ViewController类
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:.
}
}
创建帐户页面类:
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()
}
}
}
答案 0 :(得分:2)
CreateAccountPage
继承自UITableViewController
。 UITableViewController
(及其子类)的UITableView
属性必须为view
。
通过将CreateAccountPage
更改为从常规UIViewController
而不是UITableViewController
继承,可以解决您的问题。