繁体   English   中英

尝试使用XCode 5在iPhone模拟器上运行iOS应用程序时不断出现断点错误

[英]Keep getting breakpoint error when trying to run iOS application on iphone simulator with xcode 5

我刚开始第一次创建一个新的清单应用程序。

到目前为止,我已经在main.storyboard中向应用程序的UI添加了Table View对象和Table View Cell对象。

然后,我转到我的View Controller头文件,并确保将超类类型更改为“ UITableViewController”。

然后,我转到View Controller主文件并添加以下方法:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}

-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath         *)indexPath
{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChecklistItem"];

return cell;

}

我不断收到断点错误,无法使该应用程序在iPhone模拟器上运行。 我已经尝试从头开始并现在重新创建此应用程序3次,也尝试使用其他模拟器,但仍然没有任何效果。

每当我尝试运行该应用程序时,这都是调试控制台中的最终输出:

libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

另外,这是指向我尝试运行程序并获取断点错误时xcode外观的屏幕截图的链接: http : //oi40.tinypic.com/25im3kn.jpg

我过去曾多次遇到断点错误,但通常可以通过转到Debug> Deactivate Breakpoints来解决所有问题,但现在对我而言不起作用。

非常感谢您的任何帮助。

PS。 另外,这是调试控制台日志中的全部输出:

2013-12-18 18:25:55.183 Checklists[4910:70b] *** Assertion failure in -[UITableView     _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-    2903.23/UITableView.m:6246
2013-12-18 18:25:55.190 Checklists[4910:70b] *** Terminating app due to uncaught exception     'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from     tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0   CoreFoundation                      0x017385e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x014bb8b6 objc_exception_throw + 44
2   CoreFoundation                      0x01738448 +[NSException     raise:format:arguments:] + 136
3   Foundation                          0x0109bfee -[NSAssertionHandler     handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                               0x003123d5 __53-[UITableView     _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5   UIKit                               0x0028b3ef +[UIView(Animation)    performWithoutAnimation:] + 82
6   UIKit                               0x0028b438 +[UIView(Animation) _performWithoutAnimation:] + 40
7   UIKit                               0x00312226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8   UIKit                               0x0031863d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9   UIKit                               0x003186f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10  UIKit                               0x002fc774 -[UITableView _updateVisibleCellsNow:] + 2378
11  UIKit                               0x0030fe95 -[UITableView layoutSubviews] + 213
12  UIKit                               0x00294267 -[UIView(CALayerDelegate)    layoutSublayersOfLayer:] + 355
13  libobjc.A.dylib                     0x014cd81f -[NSObject performSelector:withObject:] + 70
14  QuartzCore                          0x03b462ea -[CALayer layoutSublayers] + 148
15  QuartzCore                          0x03b3a0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16  QuartzCore                          0x03b46235 -[CALayer layoutIfNeeded] + 160
17  UIKit                               0x0034f613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18  UIKit                               0x0026e177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19  UIKit                               0x0026cd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20  UIKit                               0x0026cbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21  UIKit                               0x0026cc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22  UIKit                               0x0026bd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23  UIKit                               0x0026bc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24  UIKit                               0x0026c9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25  UIKit                               0x0026ffb6 -[UIWindow setDelegate:] + 449
26  UIKit                               0x00341737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27  UIKit                               0x00265c1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28  UIKit                               0x00265d97 -[UIWindow _setHidden:forced:] + 312
29  UIKit                               0x0026602d -[UIWindow _orderFrontWithoutMakingKey] + 49
30  UIKit                               0x0027089a -[UIWindow makeKeyAndVisible] + 65
31  UIKit                               0x00223cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32  UIKit                               0x002283a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33  UIKit                               0x0023c87c -[UIApplication handleEvent:withNewEvent:] + 3447
34  UIKit                               0x0023cde9 -[UIApplication sendEvent:] + 85
35  UIKit                               0x0022a025 _UIApplicationHandleEvent + 736
36  GraphicsServices                    0x036df2f6 _PurpleEventCallback + 776
37  GraphicsServices                    0x036dee01 PurpleEventCallback + 46
38  CoreFoundation                      0x016b3d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39  CoreFoundation                      0x016b3a9b __CFRunLoopDoSource1 + 523
40  CoreFoundation                      0x016de77c __CFRunLoopRun + 2156
41  CoreFoundation                      0x016ddac3 CFRunLoopRunSpecific + 467
42  CoreFoundation                      0x016dd8db CFRunLoopRunInMode + 123
43  UIKit                               0x00227add -[UIApplication _run] + 840
44  UIKit                               0x00229d3b UIApplicationMain + 1225
45  Checklists                          0x00001b7d main + 141
46  libdyld.dylib                       0x01d7670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

PPS。 进行更改后,我的视图控制器主文件现在如下所示:

#import "ChecklistsViewController.h"

@interface ChecklistsViewController ()

@end

@implementation ChecklistsViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}

-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChecklistItem"]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault     reuseIdentifier:@"ChecklistItem"]; }

return cell;
}


@end

我仍然收到错误,现在这是控制台日志显示的内容:

2013-12-18 18:42:14.609 Checklists[5014:70b] *** Assertion failure in -[UITableView    _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-    2903.23/UITableView.m:6246
2013-12-18 18:42:14.614 Checklists[5014:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from     tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0   CoreFoundation                      0x017395e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x014bc8b6 objc_exception_throw + 44
2   CoreFoundation                      0x01739448 +[NSException raise:format:arguments:] + 136
3   Foundation                          0x0109cfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                               0x003133d5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5   UIKit                               0x0028c3ef +[UIView(Animation) performWithoutAnimation:] + 82
6   UIKit                               0x0028c438 +[UIView(Animation) _performWithoutAnimation:] + 40
7   UIKit                               0x00313226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8   UIKit                               0x0031963d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9   UIKit                               0x003196f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10  UIKit                               0x002fd774 -[UITableView _updateVisibleCellsNow:] + 2378
11  UIKit                               0x00310e95 -[UITableView layoutSubviews] + 213
12  UIKit                               0x00295267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13  libobjc.A.dylib                     0x014ce81f -[NSObject performSelector:withObject:] + 70
14  QuartzCore                          0x03b472ea -[CALayer layoutSublayers] + 148
15  QuartzCore                          0x03b3b0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16  QuartzCore                          0x03b47235 -[CALayer layoutIfNeeded] + 160
17  UIKit                               0x00350613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18  UIKit                               0x0026f177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19  UIKit                               0x0026dd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20  UIKit                               0x0026dbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21  UIKit                               0x0026dc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22  UIKit                               0x0026cd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23  UIKit                               0x0026cc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24  UIKit                               0x0026d9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25  UIKit                               0x00270fb6 -[UIWindow setDelegate:] + 449
26  UIKit                               0x00342737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27  UIKit                               0x00266c1c -[UIWindow    addRootViewControllerViewIfPossible] + 609
28  UIKit                               0x00266d97 -[UIWindow _setHidden:forced:] +     312
29  UIKit                               0x0026702d -[UIWindow _orderFrontWithoutMakingKey] + 49
30  UIKit                               0x0027189a -[UIWindow makeKeyAndVisible] + 65
31  UIKit                               0x00224cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32  UIKit                               0x002293a8 -[UIApplication    _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33  UIKit                               0x0023d87c -[UIApplication     handleEvent:withNewEvent:] + 3447
34  UIKit                               0x0023dde9 -[UIApplication sendEvent:] + 85
35  UIKit                               0x0022b025 _UIApplicationHandleEvent + 736
36  GraphicsServices                    0x036e02f6 _PurpleEventCallback + 776
37  GraphicsServices                    0x036dfe01 PurpleEventCallback + 46
38  CoreFoundation                      0x016b4d65     __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39  CoreFoundation                      0x016b4a9b __CFRunLoopDoSource1 + 523
40  CoreFoundation                      0x016df77c __CFRunLoopRun + 2156
41  CoreFoundation                      0x016deac3 CFRunLoopRunSpecific + 467
42  CoreFoundation                      0x016de8db CFRunLoopRunInMode + 123
43  UIKit                               0x00228add -[UIApplication _run] + 840
44  UIKit                               0x0022ad3b UIApplicationMain + 1225
45  Checklists                          0x00002aed main + 141
46  libdyld.dylib                       0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

问题在于代码dequeueReusableCellWithIdentifier没有返回单元格。

  1. 检查您在XIB中作为重用标识符的单元格是否设置为"ChecklistItem"
  2. 如果dequeueReusableCellWithIdentifier返回nil创建一个新单元格。

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChecklistItem"]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ChecklistItem"]; } 

那应该解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM