我在自定义UITableView
子类中以编程方式创建UIView
,该子类本身是从XIB初始化的。
这是我用来配置和设置表格视图的代码 - 它是从-initWithCoder:
内调用的:
self.tableView = [[UITableView alloc] initWithFrame:self.bounds];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.tableView.backgroundView.backgroundColor = [UIColor blackColor];
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
[self addSubview:self.tableView];
然而,一旦视图实际显示在屏幕上,表格视图.separatorStyle
已更改为UITableViewCellSeparatorStyleSingleLine
。通过在-[UITableView setSeparatorStyle:]
上设置断点,我能够在之后观察到包含表视图的视图被添加到屏幕视图层次结构中(在执行上述代码之后),UIKit本身重置此属性,使用以下堆栈跟踪:
#0 0x000000018829200c in -[UITableView setSeparatorStyle:] ()
#1 0x00000001834c7430 in __invoking___ ()
#2 0x00000001834c4fb4 in -[NSInvocation invokeUsingIMP:] ()
#3 0x00000001888d828c in __workaround10030904InvokeWithTarget_block_invoke ()
#4 0x00000001884b7c9c in +[UIView _performSystemAppearanceModifications:] ()
#5 0x00000001883422b0 in workaround10030904InvokeWithTarget ()
#6 0x00000001888d3540 in applyInvocationsToTarget ()
#7 0x00000001888d295c in +[_UIAppearance _applyInvocationsTo:window:matchingSelector:onlySystemInvocations:] ()
#8 0x00000001884c833c in __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke ()
#9 0x00000001884c82b4 in -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] ()
#10 0x00000001881d46b4 in -[UIScrollView _didChangeFromIdiom:onScreen:traverseHierarchy:] ()
#11 0x00000001884f92c0 in -[UITableView _didChangeFromIdiom:onScreen:traverseHierarchy:] ()
#12 0x00000001884c81d0 in -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] ()
#13 0x00000001881af044 in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#14 0x00000001881d4568 in -[UIScrollView _didMoveFromWindow:toWindow:] ()
#15 0x00000001881aed7c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#16 0x00000001881aed7c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#17 0x00000001881ae310 in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke ()
#18 0x00000001881ae178 in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
#19 0x00000001881bbb80 in -[UIView(Internal) _addSubview:positioned:relativeTo:] ()
#20 0x00000001883ad600 in -[_UIParallaxDimmingView didMoveToWindow] ()
#21 0x00000001881af05c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#22 0x00000001881aed7c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#23 0x00000001881ae310 in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke ()
#24 0x00000001881ae178 in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
#25 0x00000001881bbb80 in -[UIView(Internal) _addSubview:positioned:relativeTo:] ()
#26 0x000000018844ddb4 in __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_2 ()
#27 0x00000001881c2964 in +[UIView(Animation) performWithoutAnimation:] ()
#28 0x00000001883ad118 in __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke ()
#29 0x00000001884c8840 in +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] ()
#30 0x00000001883acc90 in -[_UINavigationParallaxTransition animateTransition:] ()
#31 0x00000001883666a0 in -[UINavigationController _startCustomTransition:] ()
#32 0x00000001882729b8 in -[UINavigationController _startDeferredTransitionIfNeeded:] ()
#33 0x0000000188272694 in -[UINavigationController __viewWillLayoutSubviews] ()
#34 0x00000001882725fc in -[UILayoutContainerView layoutSubviews] ()
#35 0x00000001881af778 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#36 0x0000000185bbeb2c in -[CALayer layoutSublayers] ()
#37 0x0000000185bb9738 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#38 0x0000000185bb95f8 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#39 0x0000000185bb8c94 in CA::Context::commit_transaction(CA::Transaction*) ()
#40 0x0000000185bb89dc in CA::Transaction::commit() ()
#41 0x00000001881b2944 in _UIApplicationHandleEventQueue ()
#42 0x0000000183478efc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#43 0x0000000183478990 in __CFRunLoopDoSources0 ()
#44 0x0000000183476690 in __CFRunLoopRun ()
#45 0x00000001833a5680 in CFRunLoopRunSpecific ()
#46 0x00000001848b4088 in GSEventRunModal ()
#47 0x000000018821cd90 in UIApplicationMain ()
有没有人知道导致UIKit做什么?我确定很想知道workaround10030904InvokeWithTarget
指的是什么。 : - )
在iOS 9.2.1上观察到此问题。