我试图用一些UIGestureReconizers带有MKMapView上,用户可以放置图钉并拖动它周围.它有一个callout.我正在实现这个TabbarController,也在一个NavigationController.我目前有:
1)A PanGestureRecognizer将屏幕上的Tabbar和Navigation项目设置为动画.这样可以正常运行而不会干扰平移地图.
2)TapGestureRecognizer设置为一个水龙头将1)中的两个项目动画回屏幕.
3)TapGestureRecognizer设置为两个点击允许底层MKMapView缩放功能工作.这GestureRecognizer's delegate有gestureRecognizer.shouldRecognizeSimultaneouslyWithGestureRecognizer调成true
这些设置viewDidLoad如下:
// This sets up the pan gesture recognizer to hide the bars from the UI.
let panRec: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: "didDragMap:")
panRec.delegate = self
mapView.addGestureRecognizer(panRec)
// This sets up the tap gesture recognizer to un-hide the bars from the UI.
let singleTap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: …Run Code Online (Sandbox Code Playgroud) 我正在尝试将自定义视图添加到我的标题部分UICollectionView.我有xib文件界面构建器,但我不使用storyboard.我已经检查了Interface Builder中的Section Header,但没有出现任何UICollectionReusableView,我该怎么办?
目前我正试图用HKStatisticsQuery一段时间间隔来计算步数.我正在通过shaking手机进行测试.但是,似乎我得到的结果不是最近的结果,除非:
Health.app,让它在后台运行,然后在我的应用程序中再次进行测试;UP app,让它在后台运行,然后在我的应用程序中再次进行测试.如果我强制退出Health.app或UP app,我的应用程序将无法再次获取最新数据.因此UP必须做一些我缺少的事情,但我找不到任何"重载"方法HKHealthStore,或者任何相关的选项HKQuery/HKStatisticsQuery.
我正在使用的代码非常简单,如下所示.我想知道是否有任何权限或我遗漏的任何东西.
let predicate = HKQuery.predicateForSamplesWithStartDate(date_start, endDate: NSDate(), options: HKQueryOptions.StrictStartDate)
var type = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning)
var query = HKStatisticsQuery(quantityType: type,
quantitySamplePredicate: predicate,
options: .CumulativeSum | .SeparateBySource,
completionHandler: { query, stats, error in ( /*logs here*/ ) })
let healthStore = HKHealthStore()
healthStore.executeQuery(query)
Run Code Online (Sandbox Code Playgroud)
编辑:我也尝试写一些数据,HealthKit但查询没有得到更新.
Edit2:当我说"最近的步骤计数"时,我的意思是:1.执行HKQuery; 摇动手机; 3.再次执行HKQuery.运行上面的代码2次,我总是得到相同的结果,但如果我UP在后台离开Health.app或应用程序,最新的查询得到了更新的结果.
我还尝试调用其他一些API,例如:
healthStore.enableBackgroundDeliveryForType(type, frequency:.Immediate, withCompletion:{
(success:Bool, error:NSError!) -> Void in
let …Run Code Online (Sandbox Code Playgroud)