我想我已经发布了一些关于这个问题的事情,这个问题几乎不再发生了 直到现在我正在尝试创建一个表视图!
以下是代码:
import UIKit
class ViewController: UITableViewController {
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.
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath:indexPath) as UITableViewCell
cell.textLabel.text = "Cell number \(indexPath.row)"
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return 11
}
}
btw - >我使用swift编程语言使用Xcode 6.1!
编辑 - >错误是'Thread1:signal SIGABRT'
日Thnx, appswiftgb
错误日志
2014-11-12 20:42:40.672 tableViewTutorial[5949:94056] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "vXZ-lx-hvc-view-kh9-bI-dsS" nib but didn't get a UITableView.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107377f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000108ebbbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107377e6d +[NSException raise:format:] + 205
3 UIKit 0x0000000107ee5415 -[UITableViewController loadView] + 249
4 UIKit 0x0000000107d287f9 -[UIViewController loadViewIfRequired] + 75
5 UIKit 0x0000000107d5706b -[UINavigationController _layoutViewController:] + 44
6 UIKit 0x0000000107d575b5 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
7 UIKit 0x0000000107d576b4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
8 UIKit 0x0000000107d58487 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
9 UIKit 0x0000000107d58f47 -[UINavigationController __viewWillLayoutSubviews] + 43
10 UIKit 0x0000000107e9e509 -[UILayoutContainerView layoutSubviews] + 202
11 UIKit 0x0000000107c7c973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
12 QuartzCore 0x000000010bb7ade8 -[CALayer layoutSublayers] + 150
13 QuartzCore 0x000000010bb6fa0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x000000010bb6f87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
15 QuartzCore 0x000000010badd63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
16 QuartzCore 0x000000010bade74a _ZN2CA11Transaction6commitEv + 390
17 UIKit 0x0000000107c0154d -[UIApplication _reportMainSceneUpdateFinished:] + 44
18 UIKit 0x0000000107c02238 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
19 UIKit 0x0000000107c00bf2 -[UIApplication workspaceDidEndTransaction:] + 179
20 FrontBoardServices 0x000000010aa482a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
21 CoreFoundation 0x00000001072ad53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
22 CoreFoundation 0x00000001072a3285 __CFRunLoopDoBlocks + 341
23 CoreFoundation 0x00000001072a3045 __CFRunLoopRun + 2389
24 CoreFoundation 0x00000001072a2486 CFRunLoopRunSpecific + 470
25 UIKit 0x0000000107c00669 -[UIApplication _run] + 413
26 UIKit 0x0000000107c03420 UIApplicationMain + 1282
27 tableViewTutorial 0x0000000107198f4e top_level_code + 78
28 tableViewTutorial 0x0000000107198f8a main + 42
29 libdyld.dylib 0x0000000109695145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
答案 0 :(得分:0)
尝试为您的表视图委托实现numberOfSections,它可能会崩溃,因为它已丢失。
答案 1 :(得分:0)
您应该做的是使用IB从对象库中拖动Table View Controller,然后将Class属性设置为UITableViewController
子类。
如果您只是将 Class 更改为IB中常规View Controller的UITableViewController
子类,则不会为您创建tableview。