首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppDelegate错误

AppDelegate错误
EN

Stack Overflow用户
提问于 2014-11-13 04:51:15
回答 2查看 905关注 0票数 1

我想我已经发布了一些关于这个问题的帖子,直到现在我尝试创建一个表视图时,这个问题才几乎没有发生!

代码如下:

代码语言:javascript
复制
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 
    }


}

顺便说一下,我使用的是-> 6.1,使用的是swift编程语言!

编辑信号错误是'Thread1: SIGABRT‘

thnx,appswiftgb

错误日志

代码语言:javascript
复制
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) 
EN

回答 2

Stack Overflow用户

发布于 2014-11-13 06:40:08

尝试为表视图委托实现numberOfSections,它可能会崩溃,因为缺少该委托。

票数 0
EN

Stack Overflow用户

发布于 2014-11-13 11:15:06

您应该做的是使用IB从对象库中拖动一个Table View Controller,然后将Class属性设置为您的UITableViewController子类。

如果您只是将IB中常规视图控制器的更改为UITableViewController子类,它将不会为您创建表视图。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26896299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档