对于想了解ios–Alamofire4.0RequestRetrier应该(_,retry,with,completion)不被调用的读者,本文将是一篇不可错过的文章,并且为您提供关于Alamofir
对于想了解ios – Alamofire 4.0 RequestRetrier应该(_,retry,with,completion)不被调用的读者,本文将是一篇不可错过的文章,并且为您提供关于Alamofire 是否与 iOS 11.0 兼容?、android-onLocationChanged()不被调用、animateWithDuration:animations:completion:、BeforeStep AfterStep 不被调用的有价值信息。
本文目录一览:- ios – Alamofire 4.0 RequestRetrier应该(_,retry,with,completion)不被调用
- Alamofire 是否与 iOS 11.0 兼容?
- android-onLocationChanged()不被调用
- animateWithDuration:animations:completion:
- BeforeStep AfterStep 不被调用
ios – Alamofire 4.0 RequestRetrier应该(_,retry,with,completion)不被调用
我对文档OAuth2Handler中的示例有一个非常类似的实现,它实现了RequestAdapter和RequestRetrier.
我遇到的问题是func应该(_ manager:SessionManager,重试请求:请求,有错误:错误,完成:@escaping RequestRetryCompletion)永远不会被调用.然而,RequestAdapter实现的adapt方法会被调用.
调试时,我看到SessionDelegate只在出现错误时调用(_,retry,with,completion),但返回与授权问题相关的状态代码的请求似乎不会产生错误,因此永远不会调用该方法.
我在这里错过了什么吗?
解决方法
如果是这种情况,您可以找到更多信息 here.
Alamofire 是否与 iOS 11.0 兼容?
如何解决Alamofire 是否与 iOS 11.0 兼容?
我在我的 podfile 中使用它
# Uncomment the next line to define a global platform for your project
# platform :ios,''9.0''
target ''MediaUploader'' do
# Comment the next line if you don''t want to use dynamic frameworks
use_frameworks!
# Pods for MediaUploader
pod ''SwiftyJSON'',''~> 4.0''
pod ''Alamofire'',''~> 5.2''
end
如果我在 here 中阅读了来自 Alamofire github 的文档。据说alamofire的要求是
- iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
- Xcode 11+
- Swift 5.1+
但是当我像这样为 iOS 11.0 设置部署时
我有这样的错误
似乎最低要求是针对 iOS 12.0。我做错了什么吗?我可以在 iOS 11.0 上使用 Alamofire 吗?
解决方法
Alamofire 5 完美兼容 iOS 11。
Cocoapods 不考虑您的项目最低部署目标。 (显然 iOS 12 是默认的)
您只需要在 Podfile
中取消注释此行:
# platform :ios,''9.0''
设置正确的最低部署版本:
platform :ios,''11.0''
并再次运行 pod install
。
android-onLocationChanged()不被调用
我知道有人问过这个问题,但我无法解决它.
此代码将转到请求位置部分.我知道现在的设置是不正确的选择,但我只是想获得结果,我现在不关心手机电池.我可以在Eclipse调试器中看到
"libloc" - "Latitude: XXXXX"
"libloc" - "Longitude: XXXX"
"libloc" - "Accuracy: 27000"
这意味着GPS正在工作.但是我无法获得实际位置,因为LocationListener中的所有方法均未触发.
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location loc = lm.getLastKNownLocation(LocationManager.GPS_PROVIDER);
if(loc==null){
String provider = null;
if ( lm.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
provider = LocationManager.GPS_PROVIDER;
} else {
Toast.makeText(this, "GPS not available", 3000).show();
if(lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
provider = LocationManager.NETWORK_PROVIDER;
} else {
Toast.makeText(this, "Provider Not available", 3000).show();
}
}
if(provider != null) {
lm.requestLocationUpdates(provider, 0, 0, locationListener);
}
} else {
Latitude = loc.getLatitude();
Longitude = loc.getLongitude();
}
这是我的位置侦听器对象,在顶部代码下方声明了该对象.这些方法均未调用(因此可以使用Log.d函数,以便添加断点,但此侦听器中未调用任何方法).
double Latitude = 0.0;
double Longitude = 0.0;
LocationListener locationListener = new LocationListener(){
@Override
public void onLocationChanged(Location location) {
Latitude = location.getLatitude();
Longitude = location.getLongitude();
}
@Override
public void onProviderdisabled(String provider) { Log.d("GPS", "hey THERE"); }
@Override
public void onProviderEnabled(String provider) { Log.d("GPS", "hey THERE"); }
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("GPS", "hey THERE");
}
};
附加信息,来自评论:
This is not the case. loc =
lm.getLastKNownLocation(LocationManager.GPS_PROVIDER); is always
returning null. – Overload119 50 mins agoWhat happens when you step through the rest of your code within the IF
statement? – Jack 44 mins agoI eventually get to this line: lm.requestLocationUpdates(provider, 0,
0, locationListener); Then in the debugger console message I can see
Latitude, Longitude, Accuracy showing — and its showing repeatedly,
so I’m assuming that the GPS has been activated and its getting the
location. The problem is the locationListener is not firing any of its
methods. – Overload119 41 mins agoAnd I looked at the link, my code is the same. – Overload119 41 mins
ago What is the value of provider at that point? – Jack 30 mins
agoThe value of the provider is “gps” – Overload119 15 mins ago
Can
you set some breakpoints in onLocationChanged to see when/if it is
firing? If you have already done this, after running your application
it may take a few seconds after registering the listener for it to
fire. Move your phone around some and wait. At some point it should
fire repeatedly. – Jack 12 mins agoimm.io/8vXb Here is a screenshot
— the debugger shows that the GPS is working (note that this event
pops up over and over again). I already had breaks point on
onLocationChanged() — it never reaches it even after waiting for an
extended period of time. The latitude/longitude it returns is always
the same as well. – Overload119 39 secs ago editI’ve also tried calling
lm.getLastKNownLocation(LocationManager.GPS_PROVIDER); via a button,
and click it after the console messages show that a latitude/longitude
were received. — the Location returned by the method is null though.
– Overload119 0 secs ago edit
解决方法:
我猜您的位置loc总是由getLastKNownLocation()设置,因此您的if语句永远不会评估为true.您是否调试过以查看确切的结果:
Location loc = lm.getLastKNownLocation(LocationManager.GPS_PROVIDER);
if(loc==null){ ... }
?
据我了解,您应该只使用getLastKNownLocation()来获取初始位置,然后注册您的侦听器以进行跟踪.
Here是您需要的所有信息的绝佳链接.
animateWithDuration:animations:completion:
Creates an animation block object that can be used to set up keyframe-based animations for the current view.
Declaration
(void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
Parameters
duration
The duration of the overall animation, measured in seconds. If you specify a negative value or 0, changes are made immediately and without animations.
delay
Specifies the time (in seconds) to wait before starting the animation.
options
A mask of options indicating how you want to perform the animations. For a list of valid constants, see “UIViewKeyframeAnimationOptions”.
animations
A block object containing the changes to commit to the views. Typically, you call the addKeyframeWithRelativeStartTime:relativeDuration:animations: method one or more times from inside this block. You may also change view values directly if you want those changes to animate over the full duration. This block takes no parameters and has no return value. Do not use a nil value for this parameter.
completion
A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. You can use a nil value for this parameter.
我一直不明白最后的completion什么用,参考中的回答者大概回答了。
意思是说你可以当你中断或者取消了一个动画,里面的completion会为FALSE。你要清楚,虽然取消了这个动画,但是completion block回调函数仍然会执行。如果你连接了动画序列,你想让这个序列停止的话,你只需要继续之前已经完成的动画。
如果你写一个游戏,预期是炸弹从屏幕飞过。那么你有一个动画来让炸弹移动,你的completion block写的是另外一个动画来展示炸弹爆炸,然后下面你可能调用一些方法来减分或者其他。
如果玩家点击了炸弹,你应该取消炸弹的移动动画,然后炸弹安然无恙的飞过。你之前的completion仍然会执行,所以你应该知道动画已经被执行结束或者被取消。
参考:http://stackoverflow.com/questions/8686922/what-exactly-does-bool-parameter-do-in-animatewithdurationanimationscompletion
BeforeStep AfterStep 不被调用
如何解决BeforeStep AfterStep 不被调用
我创建了一个钩子并使用了@Before、@After、@BeforeStep、@AfterStep。 1. 我设置的pom如下:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.0</version>
</dependency>
使用此设置,只有@Before、@After 工作。@BeforeStep、@AfterStep 不起作用。如何修复它。
如果我把cucumber-java的版本改成最新的6.9.1但以下无效,
import cucumber.api.java.AfterStep;
import cucumber.api.java.BeforeStep;
我应该导入哪个包?
有没有人能帮我解决一下。
解决方法
尝试使用包- io.cucumber.java
今天的关于ios – Alamofire 4.0 RequestRetrier应该(_,retry,with,completion)不被调用的分享已经结束,谢谢您的关注,如果想了解更多关于Alamofire 是否与 iOS 11.0 兼容?、android-onLocationChanged()不被调用、animateWithDuration:animations:completion:、BeforeStep AfterStep 不被调用的相关知识,请在本站进行查询。
本文标签: