小编raz*_*van的帖子

NMACCoreRouter calculateRouteWithStops 没有回调(swift)

我正在尝试在 Swift 中使用 Here API 创建路由,但我遇到了一些问题,因为从未调用完成块,所以我无法确切知道问题出在哪里。这是我的代码:

let coreRoute = NMACoreRouter()

let startPoint = NMAGeoCoordinates(latitude: latitude1, longitude: longitude1)
let waypoint1 = NMAWaypoint(geoCoordinates: startPoint)
let middlePoint = NMAGeoCoordinates(latitude: latitude2, longitude: longitude2)
let waypoint2 = NMAWaypoint(geoCoordinates: middlePoint, waypointType: NMAWaypointType.ViaWaypoint)
let endPoint = NMAGeoCoordinates(latitude: latitude3, longitude: longitude3)
let waypoint3 = NMAWaypoint(geoCoordinates: endPoint, waypointType: NMAWaypointType.StopWaypoint)

let stopList = [waypoint1, waypoint2, waypoint3] // I have also tried adding the NMAGeoCoordinates to array but still no callback

let routingMode = NMARoutingMode(routingType: NMARoutingType.Fastest, transportMode: NMATransportMode.Car, routingOptions: 0)

coreRoute.calculateRouteWithStops(stopList, …
Run Code Online (Sandbox Code Playgroud)

here-api ios swift here-ios

6
推荐指数
1
解决办法
481
查看次数

iOS在完成之前停止animateWithDuration

我有一个CollectionView,我想在用户选择的CollectionViewCell中创建一个动画.我选择使用animateKeyframesWithDuration,因为我想逐步创建自定义动画.我的代码看起来像这样:

func animate() {
    UIView.animateKeyframesWithDuration(1.0, delay: 0.0, options: .AllowUserInteraction, animations: { () -> Void in
        UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 0.5, animations: { () -> Void in
            //  First step
        })
        UIView.addKeyframeWithRelativeStartTime(0.5, relativeDuration: 0.5, animations: { () -> Void in
            //  Second step
        })
        }) { (finished: Bool) -> Void in
            if self.shouldStopAnimating {
                self.loadingView.layer.removeAllAnimations()
            } else {
                self.animate()
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

选中此选项后,将在自定义CollectionViewCell内执行此操作.问题是我想强制在某个时刻立即停止动画.但是当我这样做时,动画并没有完全停止,它只是将剩下的动画移动到另一个单元格(可能是最后一个重用的单元格?)

我不明白为什么会这样.我尝试了不同的方法,但在正常进入完成块之前,它们都没有成功停止动画

有没有人对此有任何想法?

ios animatewithduration swift ios-animations

5
推荐指数
1
解决办法
1192
查看次数