Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application crashing on [NSIndexPath setTableViewStyle:]: unrecognized selector sent to instance in ipad

Tags:

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'

Does any one knows why this is crashing? Here is some code which i am using on page control selection

        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
like image 802
Apple_Magic Avatar asked Feb 18 '23 07:02

Apple_Magic


2 Answers

There is no method like this in UITableView class called

- (id)initWithFrame:(CGRect)frame 

You need to specify the style as well, whether it is plain or grouped,

the correct method is - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;

UITableView *tableView= [[UITableView alloc]initWithFrame:frameTable style:UITableViewStylePlain]; or grouped

like image 116
Charan Avatar answered Feb 19 '23 19:02

Charan


As many people said, the problem is here:

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

You should call the setTableViewStyle: on a UITableView object, and not in an NSIndexPath one.

From the Dev Documents:

Table views can have one of two styles, UITableViewStylePlain and UITableViewStyleGrouped. When you create a UITableView instance you must specify a table style, and this style cannot be changed.

So the problem is most likely to be when you are creating the UITableView.

like image 32
Rui Peres Avatar answered Feb 19 '23 21:02

Rui Peres