假设我使用此代码将图像保存到文档directroy
let nsDocumentDirectory = NSSearchPathDirectory.DocumentDirectory
let nsUserDomainMask = NSSearchPathDomainMask.UserDomainMask
if let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true) {
if paths.count > 0 {
if let dirPath = paths[0] as? String {
let readPath = dirPath.stringByAppendingPathComponent("Image.png")
let image = UIImage(named: readPath)
let writePath = dirPath.stringByAppendingPathComponent("Image2.png")
UIImagePNGRepresentation(image).writeToFile(writePath, atomically: true)
}
}
}
Run Code Online (Sandbox Code Playgroud)
那我怎么回头呢?牢记在iOS8中,确切的路径经常变化
我想把它切成一个UIImage圆圈,然后我可以用它作为注释.我发现这个网站上的每个答案都描述了创建一个UIImageView,然后修改并显示它,但你不能将一个注释的图像设置为一个UIImageView,只有一个UIImage.我该怎么办呢?
使用Firebase作为我的后端,我有一系列的经纬度坐标字符串,如何将它们转换为CLLocationCoordinate2D以便我可以使用它们进行注释?以下是每次更新时从Firebase获取信息的代码
var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users")
UpdateRef.observeEventType(.ChildChanged, withBlock: { (snapshot) in
let MomentaryLatitude = snapshot.value["latitude"] as? String
let MomentaryLongitude = snapshot.value["longitude"] as? String
let ID = snapshot.value["ID"] as? String
println("\(MomentaryLatitude)")
var Coordinates = CLLocationCoordinate2D(latitude: MomentaryLatitude as
CLLocationDegrees, longitude: MomentaryLongitude as CLLocationDegrees)
}
Run Code Online (Sandbox Code Playgroud)
最后一行不起作用,我应该使用什么呢?
假设我的应用程序下载了一个图像,是否可以通过编程方式将其保存到Images.xcassets,以便不必再次下载图像?或者最好的选择是继续从服务器检索它?
我如何将CLLocationcoordiante转换为double,以便我可以对它进行算术运算并使用它们的大小来比较坐标?在(迅速为ios)