小编Joh*_*ieh的帖子

SWIFT Mapview MKRoutePolyline interiorPolygons:无法识别的选择器发送到实例0x14ed4b4d0

我正在尝试制作导航应用

但是当我尝试导航并显示"MKRoutePolyline"时,此应用程序崩溃

interiorPolygons:无法识别的选择器发送到实例0x14ed4b4d0"

我的代码有什么问题?

import UIKit
import MapKit
class MapViewController: UIViewController, MKMapViewDelegate {
var farm:Farm!

var currentPlacemark:CLPlacemark?

let locationManager = CLLocationManager()
var currentTransportType = MKDirectionsTransportType.Automobile
var currentRoute:MKRoute?




@IBOutlet var mapView:MKMapView!
@IBAction func showDirection(sender: AnyObject){
    let directionRequest = MKDirectionsRequest()

    directionRequest.source = MKMapItem.mapItemForCurrentLocation()
    let destinationPlacemark = MKPlacemark(placemark: currentPlacemark!)
    directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
    directionRequest.transportType = currentTransportType

    let directions = MKDirections(request: directionRequest)

    directions.calculateDirectionsWithCompletionHandler { (routeResponse, routeError) -> Void in

        guard let routeResponse = routeResponse else {
            if let routeError = routeError {
                print("Error: \(routeError)") …
Run Code Online (Sandbox Code Playgroud)

ios swift2

9
推荐指数
1
解决办法
953
查看次数

从firebase存储中检索图像以在tableView(Swift)上显示

来自New Firebase的扩展问题 检索数据并放在tableView(Swift)上

通过将Firebase代码移动到viewDidLoad,Post的所有文本部分都可以显示当前.但我仍然无法将图像放到tableView中.我检查了图像检索并且它成功了,我想我从Firebase检索的图像不在post数组中.

这是我的修复代码:

  import UIKit
  import Firebase
  import FirebaseStorage

class timelineTableViewController: UITableViewController {
var posts = [Post]()
var databaseRef: FIRDatabaseReference!
var storageRef: FIRStorageReference!

override func viewDidLoad() {
    super.viewDidLoad()
    databaseRef = FIRDatabase.database().reference()
    storageRef = FIRStorage.storage().reference()
    let userPostRef = self.databaseRef.child("posts")
    userPostRef.queryOrderedByChild("time").observeEventType(.ChildAdded, withBlock: {(snapshot) in
        if let postAdd  = snapshot.value as? NSDictionary{

            let url = snapshot.value?["postPhoto"] as! String
            let userPhotoUrl = snapshot.value?["userPhoto"] as! String
            let myPost = Post(data: postAdd)

            FIRStorage.storage().referenceForURL(url).dataWithMaxSize(10 * 1024 * 1024, completion: { (data, error) in …
Run Code Online (Sandbox Code Playgroud)

arrays asynchronous firebase swift firebase-storage

3
推荐指数
1
解决办法
8923
查看次数

新的Firebase检索数据并放在tableView(Swift)上

我使用新的Firebase制作了一个简单的社交媒体,并且我成功地将带有数据库和图像的字符串与存储一起保存,但是当它将数据检索回到表格时,不寻常的事情发生了!

所有图像检索回来随机显示并不断移位,但其他部分显示完美或当我使用返回posts.count tableView显示没有帖子.

希望有人能给我一些建议

    import UIKit
    import Firebase
    import FirebaseStorage

class timelineTableViewController: UITableViewController {
var posts = [Post]()
var databaseRef: FIRDatabaseReference!
var storageRef: FIRStorageReference!

override func viewDidLoad() {
    super.viewDidLoad()
    databaseRef = FIRDatabase.database().reference()
    storageRef = FIRStorage.storage().reference()

}


override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    // #warning Incomplete implementation, return the number of sections
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete implementation, return the number of rows
    return posts.count

}
override func tableView(tableView: …
Run Code Online (Sandbox Code Playgroud)

tableview firebase swift firebase-realtime-database firebase-storage

2
推荐指数
1
解决办法
1万
查看次数

Uibutton传递位置信息并开始在swift地图上导航

我有一个CLLocationcooridinate2d的数组内容和位置详细信息.我把它放在带有Uibutton的tableview单元格上,我正在做的是尝试通过Uibuttom传递特定的单元格信息并开始一个新的地图视图视图并开始导航.这是我的代码:

   var tripspot:[tripSpot] = [
    tripSpot( title: "????", coordinate: CLLocationCoordinate2DMake(24.149062, 120.684891), regionRadius: 300.0, location: "????????", type: "Food",cllocation:CLLocation(latitude: 24.181143,  longitude: 120.593158))


 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("MapCell") as! mapTableViewCell
    if  searchController.active{
    cell.title.text = searchResults[indexPath.row].title
    cell.location.text = searchResults[indexPath.row].location
    cell.naviButton.tag = indexPath.row
    cell.naviButton.addTarget(self, action: Selector("tapDidNavi"), forControlEvents: .TouchUpInside)

    return cell
    }else{
    cell.title.text = tripspot[indexPath.row].title
    cell.location.text = tripspot[indexPath.row].location
    cell.naviButton.tag = indexPath.row
    cell.naviButton.addTarget(self, action: Selector("tapDidNavi"), forControlEvents: .TouchUpInside)
    print(cell.naviButton.tag.description)
    return cell
    }


 }

@IBAction func tapDidNavi(sender: UIButton){



}
Run Code Online (Sandbox Code Playgroud)

谢谢你的建议!

uitableview mapkit swift

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

tableview按距离swift排序

我构建了一个视图混合与地图视图和表视图,我希望我可以按距离用户位置排序单元格,我尝试使用distanceFromLoaction方法,但它显示CLLocationCoordinate没有成员distanceFromLocaiton,还有另一种方法可以做它还是修好了?

这是我的数组结构

import UIKit
import MapKit

class tripSpot: NSObject, MKAnnotation{
var title: String?
var coordinate: CLLocationCoordinate2D
var regionRadius: Double
var location: String?
var type: String?


init(title:String , coordinate: CLLocationCoordinate2D , regionRadius: Double, location: String, type: String ){
    self.title = title
    self.coordinate = coordinate
    self.regionRadius = regionRadius
    self.location = location
    self.type = type
  }

  }
Run Code Online (Sandbox Code Playgroud)

和我的tableviewcode

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("MapCell") as! mapTableViewCell

    self.tripspot.sort({ $0.coordinate.distanceFromLoaction(self.coordinate) < $1.coordinate.distanceInKilometersTo(self.coordinate)})
    if  searchController.active{
    cell.title.text = searchResults[indexPath.row].title
    cell.location.text …
Run Code Online (Sandbox Code Playgroud)

sorting distance mapkit cllocationcoordinate2d swift

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