[ComponentTaleView tableView: heightForFooterInSection:]: нераспознанный селектор, отправленный экземпляру - PullRequest
0 голосов
/ 03 июня 2019

Я отлаживаю приложение для iOS (не разработчик для iOS), чтобы попытаться устранить ошибку для клиента, поскольку наш разработчик для iOS отсутствует, поэтому извиняюсь, поскольку это, вероятно, очевидно.Приложение аварийно завершает работу со следующим сообщением об ошибке:

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

Я отследил проблему до этой функции (операторы печати мои):

#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

#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

#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

Тестирование с включенными отпечатками консоли позволяет мне знать, что это операторы return:

return [super tableView:tableView heightForFooterInSection:section];

, которые вызывают нерегулярный селекторошибка - если я закомментирую case0 / case1 и просто оставлю по умолчанию функции приложения, но сгенерированная таблица не отформатирована правильно.У кого-нибудь есть идеи?

1 Ответ

2 голосов
/ 03 июня 2019

UITableView не реализует соответствие UITableViewDelegate, поэтому он не гарантирует, что он предоставляет метод -tableView:heightForFooterInSection:. Однако когда ComponentTableView вызывает super, он пытается найти именно этот метод. Вы не можете отправить сообщение на super, если суперкласс не реализует его.

Вместо отправки на super, чтобы получить значение «по умолчанию», подумайте о том, какое значение вы действительно хотите получить. Если это не нижний колонтитул, просто верните 0 из реализации ComponentTableView. Если оно «как бы ни было высокому, согласно Auto Layout», верните UITableViewAutomaticDimension.

Последнее замечание: во многих приложениях для iOS важно отделить табличное представление от его делегата и источника данных. Возможно, вы захотите использовать контроллер представления или другой объект в качестве делегата вместо того, чтобы создавать подклассы UITableView для реализации этих протоколов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...