小编Tim*_*ent的帖子

如何从Webserver最佳地加载MapView的位置

我在网络数据库中有2000个位置,用户应该可以在地图上选择这些位置.我可以要求网络数据库只给我一些来自当前位置的位置.

为了使一切顺利和优雅,我首先实例化MKMapView,启动CLLocationManager并等到我得到didUpdateLocations.然后我会尝试从具有完成处理程序的数据库中获取数据.

我是不是该

a)立即获取所有数据

b)以小块或块的形式获取数据?

它最好的方式是什么?

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    self.gotoCurrentLocation()
    if let userLocation = manager.location {
        GroundHelper.getAllGroundLocations(userLocation) { self.handleWaypoints($0!) }
    }
}

private func handleWaypoints(grounds: [Ground]) {
    mapView.addAnnotations(grounds)
}

// MARK: - Helper Methods

typealias GPXCompletionHandler = ([Ground]?) -> Void

class func getAllGroundLocations(userlocation: CLLocation, completionHandler: GPXCompletionHandler)  {

    let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
    dispatch_async(dispatch_get_global_queue(priority, 0), { ()->() in
        var results = RestApiManager.sharedInstance.getGPS(userlocation, limit: 50)

        // return first 50 results
        dispatch_async(dispatch_get_main_queue(), {

            var grounds = [Ground]()
            for result in …
Run Code Online (Sandbox Code Playgroud)

mkmapview swift

14
推荐指数
1
解决办法
622
查看次数

Xcode单元测试:Xcode不会在断点处停止

使用Xcode 6.3 Beta 2和单元测试我有以下问题:

当我进行单元测试时,单元测试模块中的断点可以工作,但是不会忽略被测代码中的中断代码.

有任何想法吗?

debugging xcode xctest

11
推荐指数
2
解决办法
1702
查看次数

Flutter Web 显示黑白表情符号

在 ios/android 应用程序中,表情符号可以正确显示。但使用任何网络浏览器(例如 Chrome),表情符号都会以黑白显示。我也尝试了不同的字体系列,但结果相同。

class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        return const Scaffold(
          body: Center(
            child: Text('Enjoy!  If there\'s any question')
          ),
        );
      }
    }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述

flutter

9
推荐指数
3
解决办法
3062
查看次数

在Swift中使用数组对象的谓词返回错误

当我使用Predicate过滤自定义Swift类的数组时,我得到错误:

***NSForwarding:警告:类'Plantivo1_6.Seed'的对象0x78ed21a0没有实现methodSignatureForSelector: - 提前故障
无法识别的选择器 - [Plantivo1_6.Seed valueForKey:]

如果我没记错的话,这可以在Objective-C中使用.我的错是什么?

let names = ["Tom","Mike","Marc"]
println(names)
let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", "om")
let array = (names as NSArray).filteredArrayUsingPredicate(searchPredicate)
println(array)
println()

let mySeed1 = Seed()  // Seed is a class with a `culture` String property
let mySeed2 = Seed()
let mySeed3 = Seed()
mySeed1.culture = "Tom"
mySeed2.culture = "Mike"
mySeed3.culture = "Marc"

let mySeeds = [mySeed1,mySeed2,mySeed3]
println(mySeeds)
let searchPredicate1 = NSPredicate(format: "SELF.culture CONTAINS[c] %@", "om")
let array1 = (mySeeds as NSArray).filteredArrayUsingPredicate(searchPredicate1) …
Run Code Online (Sandbox Code Playgroud)

key-value-coding nspredicate swift

7
推荐指数
1
解决办法
1370
查看次数

嵌入在UIWebView中的Youtube视频在真实设备上没有声音

这就是我嵌入视频的方式.它在模拟器中有声音,但在真实设备上没有声音(iOS 9.0.2(13A452))Xcode 7.1.1.

这是我用来播放它的代码:

if let youtubeID = youtubeID {
    let embededHTML = "<html><body><iframe src=\"http://www.youtube.com/embed/\(youtubeID)?playsinline=1\" width=\"\(width)\" height=\"\(height)\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
    cell!.webView.allowsInlineMediaPlayback = true
    cell!.webView.scalesPageToFit = true
    cell!.webView.mediaPlaybackAllowsAirPlay = true
    cell!.webView.mediaPlaybackRequiresUserAction = false

    cell!.webView.loadHTMLString(embededHTML, baseURL: NSBundle.mainBundle().bundleURL)
}
Run Code Online (Sandbox Code Playgroud)

uiwebview ios swift ios9

4
推荐指数
3
解决办法
3699
查看次数

滚动时 UITableViewCell 上的阴影消失

我有一个带有阴影的单元格的 UITableView。当我上下滚动时,单元格的阴影消失了。因为我认为这是一个重用问题,我已经只使用过这个带有阴影的单元格。这里可能有什么问题?

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        var cell = UITableViewCell()

        switch indexPath.row {
        case 3: cell = shadowBasicCellAtIndexPath(indexPath)
        case 4: cell = contentCellAtIndexPath(indexPath)
        case 5: cell = contentCellAtIndexPath(indexPath)
        case 6: cell = contentCellAtIndexPath(indexPath)
        case 11: cell = contentCellAtIndexPath(indexPath)
        default: cell = basicCellAtIndexPath(indexPath)
        }

        return cell
    }



    func contentCellAtIndexPath(indexPath: NSIndexPath) -> ContentCell {
        let cell = tableView.dequeueReusableCellWithIdentifier(contentCellIdentifier) as! ContentCell
        setTitleForCell(cell, indexPath: indexPath)
        setContentForCell(cell, indexPath: indexPath)
        return cell
    }

    func shadowBasicCellAtIndexPath(indexPath: NSIndexPath) -> ShadowBasicCell {

      //  let …
Run Code Online (Sandbox Code Playgroud)

uitableview swift

0
推荐指数
1
解决办法
1380
查看次数