应用程序崩溃[NSIndexPath setTableViewStyle:]:无法识别的选择器发送到ipad中的实例

时间:2013-03-06 13:04:19

标签: ios ipad

2013-03-06 17:38:14.764 LiveiPad[506:607] -[NSIndexPath setTableViewStyle:]: unrecognized selector sent to instance 0x57ac40
2013-03-06 17:38:14.785 LiveiPad[506:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSIndexPath setTableViewStyle:]: unrecognized selector sent to instance 0x57ac40'
*** Call stack at first throw:
(
0   CoreFoundation                      0x3182564f __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x30229c5d objc_exception_throw + 24
2   CoreFoundation                      0x318291bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3   CoreFoundation                      0x31828649 ___forwarding___ + 508
4   CoreFoundation                      0x3179f180 _CF_forwarding_prep_0 + 48
5   UIKit                               0x32a30a11 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 552
6   UIKit                               0x32a3076b -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 34
7   UIKit                               0x32a290cd -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 936
8   UIKit                               0x32a2827d -[UITableView layoutSubviews] + 140
9   UIKit                               0x329d45fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
10  CoreFoundation                      0x31792f03 -[NSObject(NSObject) performSelector:withObject:] + 22
11  QuartzCore                          0x361c5bb5 -[CALayer layoutSublayers] + 120
12  QuartzCore                          0x361c596d CALayerLayoutIfNeeded + 184
13  QuartzCore                          0x361cb1c5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
14  QuartzCore                          0x361cafd7 _ZN2CA11Transaction6commitEv + 190
15  QuartzCore                          0x361c4055 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 56
16  CoreFoundation                      0x317fca35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
17  CoreFoundation                      0x317fe465 __CFRunLoopDoObservers + 412
18  CoreFoundation                      0x317ff75b __CFRunLoopRun + 854
19  CoreFoundation                      0x3178fec3 CFRunLoopRunSpecific + 230
20  CoreFoundation                      0x3178fdcb CFRunLoopRunInMode + 58
21  GraphicsServices                    0x365b241f GSEventRunModal + 114
22  GraphicsServices                    0x365b24cb GSEventRun + 62
23  UIKit                               0x329fdd69 -[UIApplication _run] + 404
24  UIKit                               0x329fb807 UIApplicationMain + 670
25  LiveiPad                    0x000024cb main + 158
26  LiveiPad                    0x00002428 start + 40
 )
 terminate called after throwing an instance of 'NSException'

有人知道为什么会崩溃吗? 这是我在页面控制选择中使用的一些代码

        CGFloat pageWidth = self.svMinistatementTable.frame.size.width;
        int page = floor((self.svMinistatementTable.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
        self.pcMinistatementDetail.currentPage = page;

        CGRect Viewframe = CGRectMake((896*self.pcMinistatementDetail.currentPage), 0, 896, 235 );
        UIView *subview = [[UIView alloc] initWithFrame:Viewframe];
        subview.tag=self.pcMinistatementDetail.currentPage;
        CGRect frameTable= CGRectMake( 0, 0, 896, 235 );
        UITableView *tableView= [[UITableView alloc]initWithFrame: frameTable];
        tableView.tag=self.pcMinistatementDetail.currentPage;
        tableView.dataSource=self;
        tableView.delegate=self;

        if([strCallingView isEqualToString:@"Account"])
        {
            tableviewMiniStatement=tableView;

        }
        else if([strCallingView isEqualToString:@"CreditCard"])
        {
            tableviewCCUnbilledTransaction=tableView;

        }
        [subview addSubview: tableView];
        [self.svMinistatementTable addSubview:subview];
        [tableView reloadData];code here

3 个答案:

答案 0 :(得分:4)

在名为

的UITableView类中没有这样的方法
- (id)initWithFrame:(CGRect)frame 

您还需要指定样式,无论是简单还是分组,

正确的方法是- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;

UITableView *tableView= [[UITableView alloc]initWithFrame:frameTable style:UITableViewStylePlain];或已分组

答案 1 :(得分:3)

正如很多人所说,问题在于:

2013-03-06 17:38:14.764 LiveiPad[506:607] -[NSIndexPath setTableViewStyle:]: unrecognized selector sent to instance 0x57ac40

您应该在setTableViewStyle:对象上调用UITableView,而不是NSIndexPath对象。

来自开发文档:

  

表视图可以有两种样式之一,UITableViewStylePlain和   UITableViewStyleGrouped。当你创建一个UITableView实例时   必须指定表格样式,并且不能更改此样式。

因此,问题最有可能发生在您创建UITableView

答案 2 :(得分:1)

使用表格视图制作自定义单元格时出现相同错误

错误是我没有返回CellForRowAtIndexPath中的单元格:

尝试返回它,你的错误将被解决。