-[__NSCFNumber _accessibilityViewIsVisible]: unrecognized selector sent to instance

先給懶癌晚期及其閱讀恐懼癥童鞋先貼下解決方法

繼承于 UITableView 的class 不能定義 以下屬性
//@property (nonatomic, assign) NSInteger index;

只能用
@property (nonatomic, copy) NSString *index;
或者
@property (nonatomic, assign) NSInteger currentIndex;

今天我們新版的App出現(xiàn)一個很詭異的bug
首頁加載的時候會出現(xiàn)這個crash
堆棧很奇怪 定位到了main函數(shù)
而且全局?jǐn)帱c(diǎn)無效

測試和開發(fā)一開始都沒有找到重現(xiàn)路徑
國內(nèi)外的資料找了一天都沒什么頭緒
就是這時同事看到accessibility 這個單詞聯(lián)想到是否跟iOS系統(tǒng)自帶的輔助功能有關(guān)
于是抖機(jī)靈的打開了 設(shè)置-通用-輔助功能-(旁白或者語音-雙指下滑朗讀選項(xiàng))
然后在我們app首頁啟動輔助功能 就重現(xiàn)了這個crash路徑和信息

就在我們以為找到了路徑能解bug的時候又傻逼了
一個個界面屏蔽
排除了一個下午沒排除到具體的問題
最后才定位在
一個自定義的UITableView 用

[self.view addSubView: [tableViewClass alloc] init]];

不進(jìn)行任何初始化 然后調(diào)用輔助功能就會crash

于是乎用runtime把UITableView類所有成員變量打印出來
Runtime基本介紹

 unsigned int iVarCount;
    
    Ivar *iVarList = class_copyIvarList([UITableView class], &iVarCount);
    
    for (int i = 0; i < iVarCount; i++) {
        
        Ivar aVar = iVarList[i];
        
        NSLog(@"%s",ivar_getName(aVar));
    }
/*

.270772  _rowData
.270895  _rowHeight
.271007  _sectionHeaderHeight
.271166  _sectionFooterHeight
.271442  _estimatedRowHeight
.271567  _estimatedSectionHeaderHeight
.271703  _estimatedSectionFooterHeight
.271825  _visibleBounds
.271975  _subviewManager
.272076  _visibleRows
.272168  _visibleCells
.272341  _templateLayoutCells
.272469  _indexPathBeingCreated
.272635  _firstResponderIndexPath
.272918  _firstResponderView
.273159  _firstResponderViewType
.273518  _reusableTableCells
.303977  _nibMap
.304102  _nibExternalObjectsTables
.304203  _headerFooterNibMap
.304289  _headerFooterNibExternalObjectsTables
.304437  _topSeparator
.304540  _extraSeparators
.304635  _visibleHeaderViews
.304763  _visibleFooterViews
.304853  _reusableHeaderFooterViews
.304997  _highlightedIndexPaths
.305251  _selectedIndexPaths
.305517  _swipedIndexPath
.305757  _highlightedSpringLoadedIndexPath
.305988  _pendingSelectionIndexPath
.306243  _pendingDeselectionIndexPaths
.306465  _newContentView
.306702  _deleteAnimationSupport
.306981  _reorderingSupport
.307231  _backgroundView
.307460  _clearBlendingView
.307705  _wrapperView



.308015  _index



.308280  _tableHeaderBackgroundView
.308572  _tableHeaderView
.308833  _tableFooterView
.309010  _countLabel
.309535  _sectionIndexTitlesForTableView
.309802  _indexOverlayIndicatorView
.310196  _indexOverlayTimer
.310547  _indexOverlayIndicatorEventIgnoreTimer
.310699  _currentIndexTitleIndex
.310905  _indexOverlaySelectionView
.311554  _tableReloadingSuspendedCount
.311869  _sectionIndexMinimumDisplayRowCount
.312745  _updateAnimationCount
.313065  _lastFloatingSection
.314186  _insertItems
.314538  _deleteItems
.317482  _reloadItems
.318338  _moveItems
.319139  _separatorColor
.319308  _darkenedSeparatorColor
.319508  _separatorTopShadowColor
.319770  _separatorBottomShadowColor
.320000  _separatorEffect
.320275  _accessoryBaseColor
.320615  _checkmarkColor
.320829  _sectionBorderColor
.321132  _indexColor
.321425  _indexBackgroundColor
.321661  _indexTrackingBackgroundColor
.321918  _defaultSectionIndexTitles
.322157  _swipeActionController
.322353  _swipeDeletionShadowUpdateIdentifiers
.322632  _swipeGestureRecognizer
.322842  _swipeToDeleteGobblerGestureRecognizer
.323056  _swipeToDeleteCell
.323311  _updateCount
.323524  _shadowUpdateCount
.323808  _revertingShadowUpdateCount
.324104  _displayingCellContentStringIndexPath
.324302  _longPressGestureRecognizer
.324558  _upArrowLongPressGestureRecognizer
.324774  _downArrowLongPressGestureRecognizer
.325045  _upArrowTapGestureRecognizer
.325245  _downArrowTapGestureRecognizer
.325458  _longPressAutoscrollTimer
.325727  _longPressAutoscrollDirection
.326061  _sectionContentInset
.326450  _sectionBorderWidth
.326691  _sectionCornerRadius
.326956  _currentTouch
.327230  _cellClassDict
.327446  _headerFooterClassDict
.327733  _topPadding
.328026  _bottomPadding
.328300  _separatorInset
.328505  _updateCompletionHandler
.328712  _deferredEditingHandler
.328974  _hiddenSeparatorIndexPaths
.329129  _tentativeCells
.329887  _tentativeHeaderViews
.330336  _tentativeFooterViews
.330775  _clientGesturesRequiringTableGesturesToFail
.331072  _currentUpdate
.331813  _shadowUpdatesController
.332116  _preReloadVisibleRowRange
.332506  _preReloadFirstCellOffset
.332798  _lastWindow
.333015  _focusedViewType
.333177  _contentFocusContainerGuide
.333452  _constants
.333647  _targetIndexPathForScrolling
.333843  _targetOffsetToIndexPathForScrolling
.334062  _indexRetargetFeedbackGenerator
.334306  _sectionChangeFeedbackGenerator
.334557  _reorderFeedbackGenerator
.334768  _performUsingPresentationValuesCount
.334927  _prefetchDataSource
.335167  _prefetchContext
.335368  _coalescedContentSizeDelta
.335531  _tableFlags
.335816  _dragDelegate
.336066  _dropDelegate
.336295  _focusedCellIndexPath
.336487  _focusedCell
.336725  _indexPathToFocus
.336980  _dragController
.337142  _dropController
.337628  _placeholderContexts
.337862  _dragSourceDelegate
.338106  _dragDestinationDelegate
.338290  _cachedSectionIndexBarInsets
*/

發(fā)現(xiàn)系統(tǒng)UITableView其中有一個私有屬性Index是String類型的 所以由于各種原因(蘋果的bug) 會導(dǎo)致app崩潰 而且沒有任何信息

找了很多資料找不到解決辦法
因此和大家分享一下我們的解決方法
如果幫助到大家可以點(diǎn)個贊
鼓勵up主繼續(xù)創(chuàng)作
么么噠 (*  ̄3)(ε ̄ *)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 用到的組件 1、通過CocoaPods安裝 2、第三方類庫安裝 3、第三方服務(wù) 友盟社會化分享組件 友盟用戶反饋 ...
    SunnyLeong閱讀 15,205評論 1 180
  • 從小到大,一直擁有別人眼中羨慕的身材,高挑又苗條,而且怎么吃也不胖。對于那些喝水都要胖的朋友來說,一聊起來牙根都恨...
    北木山閱讀 240評論 1 3
  • 良性甲狀腺結(jié)節(jié)如何吃藥,是否需要手術(shù)? 甲狀腺結(jié)節(jié)分兩種一種是實(shí)性的,一種是囊性的,實(shí)性相當(dāng)于實(shí)心,囊性里頭裝的是...

友情鏈接更多精彩內(nèi)容