小编And*_*son的帖子

swift中的UnsafeMutablePointer替换Obj-C中正确大小的C数组

我如何与swift中用于获取大小的C数组的函数进行交互?

我阅读了与C APIS的交互,但仍然无法弄清楚这一点.

func getCoordinates(_ coords:UnsafeMutablePointer<CLLocationCoordinate2D>,range range: NSRange)状态的coords参数的文档:"在输入时,您必须提供足够大的C数组结构以容纳所需数量的坐标.在输出时,此结构包含请求的坐标数据."

我尝试了几件事,最近一次:

var coordinates: UnsafeMutablePointer<CLLocationCoordinate2D> = nil
polyline.getCoordinates(&coordinates, range: NSMakeRange(0, polyline.pointCount))
Run Code Online (Sandbox Code Playgroud)

我是否必须使用以下内容:

var coordinates = UnsafeMutablePointer<CLLocationCoordinate2D>(calloc(1, UInt(polyline.pointCount)))
Run Code Online (Sandbox Code Playgroud)

把头发拉出来......有什么想法吗?

mkpolyline swift

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

使用大小类时,UITableViewCell子视图报告的宽度不正确

出于某种原因,在xcode 6中使用大小类时,我的单元格中的子视图的宽度不正确.我有一个自动UIImageView布局用于尺寸调整(常量:顶部为10,L/R,底部).

从以下地址拨打以下电话tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!):

println("w: \(cell.mapSnapshotImageView.bounds.size.width) h: \(cell.mapSnapshotImageView.bounds.size.height)")
Run Code Online (Sandbox Code Playgroud)

我总是得到:

w: 580.0 h: 80.0
Run Code Online (Sandbox Code Playgroud)

即使它应该可以w: 300.0 h: 80.0根据我的320x100在iPhone 5S细胞.

一切都正确显示,但我想使用子视图的宽度进行其他子视图的一些计算.关于为什么会发生这种情况的任何想法?错误报告或按设计工作?

编辑:

此问题仅适用于最初加载的单元格.当细胞被重复使用时,问题不会出现.println重用单元格的输出:

w: 300.0 h: 80.0
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift xcode6

12
推荐指数
2
解决办法
7042
查看次数

解析云查询以获取具有最接近的GeoPoint的对象

我在编写Parse查询以获取具有对输入的GeoPoint的CLOSEST的GeoPoint的Parse对象时遇到问题.目前,代码似乎返回最近创建的对象.

码:

// check Parse for infections around passed GeoPoint
Parse.Cloud.define("InfectionCheck_BETA", function(request, response) {

var returnCount;

var geoPoint = request.params.geoPoint;
var query = new Parse.Query("InfectedArea");
query.withinMiles("centerPoint", geoPoint, 1); // check for infections within one mile

Parse.Promise.as().then(function() {
    // query for count of infection in area, this is how we get severity
    return query.count().then(null, function(error) {
        console.log('Error getting InfectedArea. Error: ' + error);
        return Parse.Promise.error(error);
    });

}).then(function(count) {
    if (count <= 0) {
        // no infected areas, return 0
        response.success(0);
    } …
Run Code Online (Sandbox Code Playgroud)

javascript parse-platform parse-cloud-code

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

如何为UIButton内容对齐中的更改设置动画

UIButton的几个属性本身并不具有动画效果.其中一个属性是contentHorizontalAlignment财产.在没有运气的情况下搜索SO后,我想出了下面的答案来解决"不可动画"的问题.

cocoa-touch objective-c ios

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