[英][ComponentTaleView tableView:heightForFooterInSection:]: unrecognized selector sent to instance
I'm debugging an iOS app (not an iOS developer) to try and solve a bug for a client as our iOS dev is away so apologies as this is probably obvious. 我正在调试一个iOS应用程序(不是iOS开发人员)以尝试解决客户端的错误,因为我们的iOS开发人员已经不在了,因此道歉很明显。 The app is crashing with the following error message: 该应用程序崩溃,并显示以下错误消息:
2019-06-03 16:34:05.292250+0100 SBD POP[75510:2099884] -[ComponentTableView tableView:heightForFooterInSection:]: unrecognized selector sent to instance 0x7f901d929200
2019-06-03 16:34:05.298376+0100 SBD POP[75510:2099884] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ComponentTableView tableView:heightForFooterInSection:]: unrecognized selector sent to instance 0x7f901d929200'
*** First throw call stack:
(
0 CoreFoundation 0x00000001126da6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x00000001116fdac5 objc_exception_throw + 48
2 CoreFoundation 0x00000001126f8ab4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x000000011c8a0c3d -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x00000001126df1a1 ___forwarding___ + 769
5 CoreFoundation 0x00000001126e1238 _CF_forwarding_prep_0 + 120
6 SBD POP 0x000000010d1852b6 -[ComponentTableView tableView:heightForFooterInSection:] + 230
7 UIKitCore 0x000000011cab6106 -[UITableView _classicHeightForFooterInSection:] + 167
8 UIKitCore 0x000000011cabb02c -[UITableView _heightForFooterInSection:] + 34
9 UIKitCore 0x000000011cacabc4 -[UISectionRowData heightForFooterInSection:canGuess:] + 91
10 UIKitCore 0x000000011cad2277 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 653
11 UIKitCore 0x000000011ca890d7 -[UITableView _rectForFooterInSection:usingPresentationValues:] + 166
12 UIKitCore 0x000000011cab169e -[UITableView _hasHeaderFooterBelowRowAtIndexPath:] + 175
13 UIKitCore 0x000000011ca90c2f -[UITableView _shouldDrawSeparatorAtBottomOfSection:] + 126
14 UIKitCore 0x000000011caacf3d -[UITableView _setupCell:forEditing:atIndexPath:canEdit:editingStyle:shouldIndentWhileEditing:showsReorderControl:accessoryType:animated:updateSeparators:] + 1264
15 UIKitCore 0x000000011caad23f -[UITableView _setupCell:forEditing:atIndexPath:animated:updateSeparators:] + 665
16 UIKitCore 0x000000011ca9b3cb __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 2569
17 UIKitCore 0x000000011cd34a19 +[UIView(Animation) performWithoutAnimation:] + 90
18 UIKitCore 0x000000011ca9a8db -[UITableView _configureCellForDisplay:forIndexPath:] + 237
19 UIKitCore 0x000000011caad6bf -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 911
20 UIKitCore 0x000000011caadb65 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
21 UIKitCore 0x000000011ca75d20 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2870
22 UIKitCore 0x000000011ca95e37 -[UITableView layoutSubviews] + 165
23 UIKitCore 0x000000011cd429c1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
24 QuartzCore 0x000000010e051eae -[CALayer layoutSublayers] + 173
25 QuartzCore 0x000000010e056b88 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
26 UIKitCore 0x000000011cd2d985 -[UIView(Hierarchy) layoutBelowIfNeeded] + 646
27 UIKitCore 0x000000011c1d5ec8 -[UINavigationController _layoutViewController:] + 1756
28 UIKitCore 0x000000011c1cfad8 -[UINavigationController _layoutTopViewController] + 223
29 UIKitCore 0x000000011c1cde01 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 732
30 UIKitCore 0x000000011ccfa4b6 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 418
31 UIKitCore 0x000000011ccfa779 -[UINavigationTransitionView _cleanupTransition] + 608
32 UIKitCore 0x000000011cd098ff -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 343
33 UIKitCore 0x000000011cd0516d +[UIViewAnimationState popAnimationState] + 319
34 UIKitCore 0x000000011ccfa229 -[UINavigationTransitionView transition:fromView:toView:] + 2363
35 UIKitCore 0x000000011c1d6efb -[UINavigationController _startTransition:fromViewController:toViewController:] + 3222
36 UIKitCore 0x000000011c1d73b5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 896
37 UIKitCore 0x000000011c1d86a7 -[UINavigationController __viewWillLayoutSubviews] + 150
38 UIKitCore 0x000000011c1b938d -[UILayoutContainerView layoutSubviews] + 217
39 UIKitCore 0x000000011cd429c1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
40 QuartzCore 0x000000010e051eae -[CALayer layoutSublayers] + 173
41 QuartzCore 0x000000010e056b88 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
42 QuartzCore 0x000000010e062ee4 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 72
43 QuartzCore 0x000000010dfd23aa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 328
44 QuartzCore 0x000000010e009584 _ZN2CA11Transaction6commitEv + 608
45 UIKitCore 0x000000011c86ed8a _UIApplicationFlushRunLoopCATransactionIfTooLate + 150
46 UIKitCore 0x000000011c961f5f __handleEventQueueInternal + 6845
47 CoreFoundation 0x0000000112641be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
48 CoreFoundation 0x0000000112641463 __CFRunLoopDoSources0 + 243
49 CoreFoundation 0x000000011263bb1f __CFRunLoopRun + 1231
50 CoreFoundation 0x000000011263b302 CFRunLoopRunSpecific + 626
51 GraphicsServices 0x0000000117f812fe GSEventRunModal + 65
52 UIKitCore 0x000000011c874ba2 UIApplicationMain + 140
53 SBD POP 0x000000010d16fc00 main + 112
54 libdyld.dylib 0x000000011606f541 start + 1
55 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I've tracked the problem down to this function (print statements are mine): 我已将问题归结为该功能(打印语句是我的):
#import "ComponentTableView.h"
#import "Component.h"
#import "CoreData.h"
#import "UIPositioning.h"
#import "UIView+utils.h"
#import "UIColor+appColors.h"
#import "TotalRowView.h"
#import "NSUserDefaults+Preferences.h"
@implementation ComponentTableView
//Other code/functions here
#pragma mark - UITableViewDelegate
//Other code/functions here
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
printf("Section: %f\n", section);
switch (section) {
case 0:
{
printf("Section - Case 0\n");
if([self showSectionFooters])
{
printf("Section - Case 0 - If Statement\n");
return [super tableView:tableView heightForFooterInSection:section];
}
break;
}
case 1:
{
printf("Section - Case 1\n");
return [super tableView:tableView heightForFooterInSection:section];
break;
}
default:
{
printf("Section - Default\n");
break;
}
}
return 0;
}
ComponentTableView.h ComponentTableView.h
#import "DisplayItemTableView.h"
@class ComponentTableView;
@protocol ComponentTableViewDelegate <NSObject>
- (void)onComponentTableControllerDidChangeContent:(ComponentTableView*) componentTableView;
@optional
- (void)onComponentTableViewEdit:(ComponentTableView*) componentTableView;
- (void)onDisplayItemTableVerifiedComponentsChanged:(ComponentTableView*) componentTableView;
@end
@interface ComponentTableView : DisplayItemTableView <DisplayItemViewDelegate>
@property BOOL includePreviewImage;
@property BOOL standComponentIsMandatory;
-(BOOL) outOfStock;
@property (strong, nonatomic) NSCountedSet<NSString*>* verifiedComponentSet;
@property (weak, nonatomic) id<ComponentTableViewDelegate> parentDelegate;
@property (strong, nonatomic) Component* stand;
-(CGFloat) contentHeight;
-(CGFloat) retailCost;
-(CGFloat) merchCost;
- (id) initWithComponentUIDSet:(NSCountedSet<NSString*> *) componentUIDSet;
+(CGFloat) contentHeight:(NSCountedSet*) uidset;
@end
DisplayItemTableView.h DisplayItemTableView.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "DisplayItemView.h"
#import "TotalRowView.h"
@class DisplayItemTableView;
@interface DisplayItemTableView : UITableView<UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate>
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) RetailTotalView *retailTotalView;
@property (strong, nonatomic) MerchandisingTotalView *merchTotalView;
-(id) initWithHeight:(CGFloat) height;
-(id) initWithTopAndHeight:(CGFloat) top :(CGFloat) height;
+(CGFloat) displayItemHeight:(NSString*) name :(NSString*) sku :(BOOL) includePreviewImage;
+(UIColor*) separatorColor;
@end
Testing with the console prints turned on lets me know that it's the return statements: 在打开控制台打印功能的情况下进行的测试使我知道这是return语句:
return [super tableView:tableView heightForFooterInSection:section];
Which are causing the unregonised selector error - if I comment out case0/case1 and just leave the default the app functions but the table being generated isn't formatted correctly. 这会导致非注册选择器错误-如果我注释掉case0 / case1并保留默认值,则应用程序功能不正确,但是生成的表格式不正确。 Anyone have any ideas? 有人有想法么?
UITableView does not implement conformance to UITableViewDelegate, so it doesn't guarantee that it provides the method -tableView:heightForFooterInSection:
. UITableView没有实现与UITableViewDelegate的一致性,因此不能保证提供了-tableView:heightForFooterInSection:
方法。 However, when ComponentTableView calls super
, it's attempting to find exactly that method. 但是,当ComponentTableView调用super
,它正在尝试完全找到该方法。 You can't send a message to super
when the superclass doesn't implement it. 当超类未实现消息时,您无法将消息发送给super
。
Instead of sending to super
to get a "default" value, think about what you actually want the value to be. 与其发送到super
以获取“默认”值,不如考虑您实际希望的值是什么。 If it's "no footer," simply return 0 from ComponentTableView's implementation. 如果“没有页脚”,则只需从ComponentTableView的实现中返回0。 If it's "however tall Auto Layout says," return UITableViewAutomaticDimension
. 如果是“无论如何,自动布局都会显示”,则返回UITableViewAutomaticDimension
。
One last note: many iOS apps make a point of separating the table view from its delegate and data source. 最后一点:许多iOS应用强调将表视图与其委托和数据源分开。 You may want to consider using a view controller or other object as the delegate, instead of subclassing UITableView to implement those protocols. 您可能要考虑使用视图控制器或其他对象作为委托,而不是将UITableView子类化以实现那些协议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.