小编tra*_*233的帖子

如何在Swift中使用完成处理程序创建一个函数?

我只是好奇我将如何处理这个问题.如果我有一个函数,并且我想在完全执行时发生某些事情,我该如何将它添加到函数中?谢谢

function completionhandler swift

104
推荐指数
5
解决办法
9万
查看次数

使用UIBezierPath获取"无效上下文"错误

我试图让这个绘制一条平移手势发生的线.问题是当我尝试使用此代码时

var firstPoint: CGPoint!

var path: UIBezierPath!

@IBAction func panned(gesture: UIPanGestureRecognizer) {
    switch gesture.state {
    case .Began: firstPoint = gesture.locationOfTouch(0, inView: view)
    case .Ended: gesture.cancelsTouchesInView = true
    case .Changed:
        path.moveToPoint(firstPoint)
        path.addLineToPoint(gesture.translationInView(view))
        path.stroke()
    default: break
    }
}
Run Code Online (Sandbox Code Playgroud)

...我得到了多个错误,我不太清楚该怎么做.

Apr 2 17:40:03 MacBook-Pro.local Paint[6729] <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is …
Run Code Online (Sandbox Code Playgroud)

uibezierpath swift

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

标签 统计

swift ×2

completionhandler ×1

function ×1

uibezierpath ×1