我有一个简单的喷雾客户端:
val pipeline = sendReceive ~> unmarshal[GoogleApiResult[Elevation]]
val responseFuture = pipeline {Get("http://maps.googleapis.com/maps/api/elevation/jsonlocations=27.988056,86.925278&sensor=false") }
responseFuture onComplete {
case Success(GoogleApiResult(_, Elevation(_, elevation) :: _)) =>
log.info("The elevation of Mt. Everest is: {} m", elevation)
shutdown()
case Failure(error) =>
log.error(error, "Couldn't get elevation")
shutdown()
}
Run Code Online (Sandbox Code Playgroud)
完整代码可以在这里找到.
我想模拟服务器的响应来测试Success和Failure案例中的逻辑.我找到的唯一相关信息是在这里,但我无法使用蛋糕模式来模拟sendReceive方法.
任何建议或例子将不胜感激.
当用户在webview中滚动时,我正在尝试实现"消失"的URL栏.调用下面的函数- (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;
}];
}
Run Code Online (Sandbox Code Playgroud)
处于冻结状态的已暂停应用程序的完整堆栈跟踪:
* 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 …Run Code Online (Sandbox Code Playgroud)