使用CGAffineTransformScale进行动画冻结应用程序

时间:2014-07-08 18:55:36

标签: ios scroll core-animation

我正在努力实施一个"消失" url bar,当用户在webview中滚动时。 以下函数在- (void)scrollViewDidScroll:(UIScrollView *)scrollView中调用。

对于特定网页,该应用程序完全冻结并使用100%CPU。从反复试验中我们得出结论,删除CGAffineTransformScale修正了这个问题。我试图理解为什么会发生这种情况以及我如何实现相同的功能。

- (void)collapseQueryBox
{

    _URLBarState = CLQURLBarStateCollapsing;
    _queryBoxViewHeightConstraint.constant = COLLAPSED_QUERYBOX_HEIGHT;

    [UIView animateWithDuration:COLLAPSE_ANIMATION_DURATION  animations:^{
        _webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        _queryLabel.transform = CGAffineTransformScale(_queryLabel.transform, COLLAPSE_ANIMATION_SCALE_FACTOR, COLLAPSE_ANIMATION_SCALE_FACTOR);
        _queryLabel.layer.backgroundColor = [UIColor clearColor].CGColor;
        [_browserContainerView layoutIfNeeded];
    } completion:^(BOOL finished) {
        _URLBarState = CLQURLBarStateCollapsed;
    }];
}

处于冻结状态的已暂停应用的完整堆栈跟踪:

* thread #1: tid = 0xcbf9f, 0x025b40be libobjc.A.dylib`objc_msgSend + 26, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x025b40be libobjc.A.dylib`objc_msgSend + 26
    frame #1: 0x008cf411 Foundation`-[NSISEngine variableToWorkOnAmongVariablesWithIntegralizationViolationsIgnoringLostCauses:varsAlreadyAdjusted:] + 491
    frame #2: 0x00a41ea3 Foundation`__44-[NSISEngine fixupIntegralizationViolations]_block_invoke + 1285
    frame #3: 0x00a4368c Foundation`-[NSISEngine withBehaviors:performModifications:] + 107
    frame #4: 0x008cf21a Foundation`-[NSISEngine withoutOptimizingAtEndRunBlockWithAutomaticOptimizationDisabled:] + 48
    frame #5: 0x008cf1d9 Foundation`-[NSISEngine fixupIntegralizationViolations] + 96
    frame #6: 0x008ceef8 Foundation`-[NSISEngine optimize] + 204
    frame #7: 0x008d57e3 Foundation`-[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 336
    frame #8: 0x00a43e23 Foundation`-[NSISEngine tryToChangeConstraintSuchThatMarker:isReplacedByMarkerPlusDelta:undoHandler:] + 489
    frame #9: 0x00a4b2d5 Foundation`-[NSLayoutConstraint _tryToChangeContainerGeometryWithUndoHandler:] + 578
    frame #10: 0x008c8d4f Foundation`-[NSLayoutConstraint _setSymbolicConstant:constant:] + 384
    frame #11: 0x008cb6a1 Foundation`-[NSLayoutConstraint setConstant:] + 52
    frame #12: 0x00e398a5 UIKit`-[UIScrollView setContentSize:] + 566
    frame #13: 0x01030a5a UIKit`-[UITableViewCell _updateWrapperContentInset] + 117
    frame #14: 0x0103963a UIKit`-[UITableViewCell setFrame:] + 701
    frame #15: 0x00e1b7b0 UIKit`-[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 840
    frame #16: 0x00e1c552 UIKit`-[UIView(Geometry) _resizeWithOldSuperviewSize:] + 290
    frame #17: 0x00e1c5aa UIKit`-[UIView(Geometry) resizeWithOldSuperviewSize:] + 80
    frame #18: 0x00e1b185 UIKit`__46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke + 87
    frame #19: 0x028a1d86 CoreFoundation`__53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
    frame #20: 0x028a1c5f CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
    frame #21: 0x00e1b115 UIKit`-[UIView(Geometry) resizeSubviewsWithOldSize:] + 149
    frame #22: 0x00e19c4e UIKit`-[UIView(Geometry) setFrame:] + 559
    frame #23: 0x00e1b7b0 UIKit`-[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 840
    frame #24: 0x00e1c552 UIKit`-[UIView(Geometry) _resizeWithOldSuperviewSize:] + 290
    frame #25: 0x00e1c5aa UIKit`-[UIView(Geometry) resizeWithOldSuperviewSize:] + 80
    frame #26: 0x00e1b185 UIKit`__46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke + 87
    frame #27: 0x028a1d86 CoreFoundation`__53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
    frame #28: 0x028a1c5f CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
    frame #29: 0x00e1b115 UIKit`-[UIView(Geometry) resizeSubviewsWithOldSize:] + 149
    frame #30: 0x00eadc1a UIKit`-[UITableView resizeSubviewsWithOldSize:] + 98
    frame #31: 0x00e1c819 UIKit`-[UIView(Geometry) setBounds:] + 510
    frame #32: 0x00e39627 UIKit`-[UIScrollView setBounds:] + 1036
    frame #33: 0x00eadf5f UIKit`-[UITableView setBounds:] + 260
    frame #34: 0x00e1befd UIKit`-[UIView(Geometry) _applyISEngineLayoutValues] + 324
    frame #35: 0x00e1c4c0 UIKit`-[UIView(Geometry) _resizeWithOldSuperviewSize:] + 144
    frame #36: 0x00e457bb UIKit`-[UIScrollView _resizeWithOldSuperviewSize:] + 73
    frame #37: 0x00e1c5aa UIKit`-[UIView(Geometry) resizeWithOldSuperviewSize:] + 80
    frame #38: 0x00e1b185 UIKit`__46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke + 87
    frame #39: 0x028a1d86 CoreFoundation`__53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
    frame #40: 0x028a1c5f CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
    frame #41: 0x00e1b115 UIKit`-[UIView(Geometry) resizeSubviewsWithOldSize:] + 149
    frame #42: 0x0145961c UIKit`-[UIView(AdditionalLayoutSupport) _is_layout] + 158
    frame #43: 0x00e20336 UIKit`-[UIView(Hierarchy) layoutSubviews] + 80
    frame #44: 0x00e2d964 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    frame #45: 0x025b682b libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70
    frame #46: 0x01df345a QuartzCore`-[CALayer layoutSublayers] + 148
    frame #47: 0x01de7244 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 380
    frame #48: 0x01de70b0 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26
    frame #49: 0x01d4d7fa QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 294
    frame #50: 0x01d4eb85 QuartzCore`CA::Transaction::commit() + 393
    frame #51: 0x01d4f258 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
    frame #52: 0x027ed36e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    frame #53: 0x027ed2bf CoreFoundation`__CFRunLoopDoObservers + 399
    frame #54: 0x027cb254 CoreFoundation`__CFRunLoopRun + 1076
    frame #55: 0x027ca9d3 CoreFoundation`CFRunLoopRunSpecific + 467
    frame #56: 0x027ca7eb CoreFoundation`CFRunLoopRunInMode + 123
    frame #57: 0x041895ee GraphicsServices`GSEventRunModal + 192
    frame #58: 0x0418942b GraphicsServices`GSEventRun + 104
    frame #59: 0x00dbef9b UIKit`UIApplicationMain + 1225

0 个答案:

没有答案