小编ina*_*atu的帖子

更改的值与编辑UITextField的更改事件之间的区别是什么

我正在阅读一本关于swift中的设计模式的书,并且有一个程序,当步进器的值改变或与其关联的文本字段发生变化时,方法会得到通知,这里是方法

@IBAction func stockLevelDidChange(sender: AnyObject) {
    println("Method Trigged")
        if var currentCell = sender as? UIView {
            while (true) {
                currentCell = currentCell.superview!;
                if let cell = currentCell as? ProductTableViewCell {
                    if let id = cell.productID? {

                        var newStockLevel:Int?;

                        if let stepper = sender as? UIStepper {
                            newStockLevel = Int(stepper.value);
                        } else if let textfield = sender as? UITextField {
                            if let newValue = textfield.text.toInt()? {
                                newStockLevel = newValue;
                            }
                        }

                        if let level = newStockLevel {
                            products[id].4 = level;
                            cell.stockStepper.value …
Run Code Online (Sandbox Code Playgroud)

uitextfield ios

10
推荐指数
2
解决办法
4380
查看次数

CIConstantColorGenerator CIFilter 在 Playground 中使用 Swift 2.0 失败并出现错误

我尝试使用以下代码行创建一个滤色器

let parameters = [kCIInputColorKey: CIColor(string: "0.5 0.7 0.3 1.0")]
let colorFilter = CIFilter(name: "CIConstantColorGenerator",    withInputParameters: parameters)
colorFilter?.outputImage
Run Code Online (Sandbox Code Playgroud)

但调试控制台输出滚动信息

 <Error>: CGImageProviderCreate: invalid image provider size: 1.79769e+308 x 1.79769e+308.
<Error>: CGImageCreate: invalid image width.
<Error>: ImageIO: CGImageDestinationFinalize image destination must have at least one image
CGImageDestinationFinalize failed for output type 'public.tiff'
Run Code Online (Sandbox Code Playgroud)

谢谢,加上:我尝试在 Swift 项目中编写此代码,它工作正常,但在操场上工作时,只显示此错误

cifilter swift-playground

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

标签 统计

cifilter ×1

ios ×1

swift-playground ×1

uitextfield ×1