小编use*_*374的帖子

如何拖动MKMapView拖动注释?(IOS)

我有一个包含MKMapView的UIViewController.我通过以下代码在当前位置添加了注释:

import UIKit
import MapKit
class LocationViewController: UIViewController , MKMapViewDelegate ,CLLocationManagerDelegate {
    @IBOutlet weak var mapView: MKMapView!
    var locationManager: CLLocationManager!
    let regionRadius: CLLocationDistance = 1000
    var token: dispatch_once_t = 0
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        locationManager = CLLocationManager()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }

func centerMapOnLocation(location: CLLocation) {
    let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate,
        regionRadius * 2.0, regionRadius * 2.0)
    mapView.setRegion(coordinateRegion, animated: true)
}

func mapView(mapView: MKMapView, didUpdateUserLocation userLocation: MKUserLocation) {

    if ((userLocation.coordinate.latitude != 0.0) && …
Run Code Online (Sandbox Code Playgroud)

mapkit mkmapview ios swift

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

如何在C中读/写UTF8文本文件?

我试图从文本文件中读取UTF8文本,然后将其中一些文本打印到另一个文件.我正在使用Linux和gcc编译器.这是我正在使用的代码:

#include <stdio.h>
#include <stdlib.h>

int main(){
    FILE *fin;
    FILE *fout;
    int character;
    fin=fopen("in.txt", "r");
    fout=fopen("out.txt","w");
    while((character=fgetc(fin))!=EOF){
        putchar(character); // It displays the right character (UTF8) in the terminal
        fprintf(fout,"%c ",character); // It displays weird characters in the file
    }
    fclose(fin);
    fclose(fout);
    printf("\nFile has been created...\n");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它现在适用于英文字符.

c linux gcc utf-8

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

标签 统计

c ×1

gcc ×1

ios ×1

linux ×1

mapkit ×1

mkmapview ×1

swift ×1

utf-8 ×1