小编Zan*_*der的帖子

ios11 MKAnnotation没有显示两个注释

当我将注释添加到地图时,它们有时会显示,有时不会取决于它们彼此之间的距离.如果他们在同一个房子里,就说一个人不会出现.我如何让他们两个显示?我是否需要制作自定义注释类?我听说ios11有一个丛集功能,我需要使用它吗?这是代码(删节):

import UIKit
import MapKit
import Firebase

class GameViewController: UIViewController {


@IBOutlet weak var mapView: MKMapView!

fileprivate var locations = [CLLocation]()
fileprivate var userLocations = [(loc: CLLocation, name: String, team: String)]()
fileprivate var userAnnotations = [MKAnnotation]()
fileprivate var hasBeenUP = false

var ref: FIRDatabaseReference!
let uid = FIRAuth.auth()!.currentUser!.uid

var timer = Timer()
var timeLeft = 0.0
var firstTimer = Timer()

var name = ""
var team = ""

override func viewDidLoad() {
    super.viewDidLoad()
    let center = CLLocationCoordinate2D(latitude: 47.786769, longitude: -20.413634) …
Run Code Online (Sandbox Code Playgroud)

mapkit ios swift ios11

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

Multipeer Connectivity foundDevice两次

我有下面的代码,我的目标是让mac识别具有Multipeer Connectivity的iOS设备.这在大多数情况下起作用,除了当我运行这两个时我得到两个 "FOUND !!!" 在控制台中.我怎样才能解决这个问题?

这是我的iOS设备代码:

import UIKit
import MultipeerConnectivity

class ViewController: UIViewController, MCNearbyServiceBrowserDelegate,      MCNearbyServiceAdvertiserDelegate {


let browser = MCNearbyServiceBrowser(peer: MCPeerID(displayName: "iOS Device"), serviceType: "example-test")
let peerID = MCPeerID(displayName: "iOS Device")
let advertiser = MCNearbyServiceAdvertiser(peer: MCPeerID(displayName: "iOS Device"), discoveryInfo: nil, serviceType: "example-test")



override func viewDidLoad() {
    super.viewDidLoad()
    advertiser.delegate = self
    advertiser.startAdvertisingPeer()
    browser.delegate = self
    browser.startBrowsingForPeers()
}

func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {

}

func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: Error) {

}

func browser(_ browser: MCNearbyServiceBrowser, foundPeer …
Run Code Online (Sandbox Code Playgroud)

ios multipeer-connectivity swift

4
推荐指数
1
解决办法
473
查看次数

标签 统计

ios ×2

swift ×2

ios11 ×1

mapkit ×1

multipeer-connectivity ×1