UIView没有名为'delegate的成员

摩根·王尔德

有点奇怪,但是我似乎无法为UIView对象设置委托那个财产去哪儿了?

class ViewController: UIViewController {

    // Properties
    var subView: UIView!
    var subSubView: UIView!

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        println("init(coder aDecoder: NSCoder)")

        subView = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
        subSubView = UIView(frame: CGRect(x: 10, y: 10, width: 80, height: 80))

        subView.backgroundColor = UIColor.redColor()
        subSubView.backgroundColor = UIColor.blueColor()

        subView.delegate = self    // Error
        subSubView.delegate = self // Error
    }
}

我需要代表,以便可以观察子视图的生命周期。

雾雾

UIView没有(也从未有过)名为的属性delegate

这就是为什么您会收到此错误的原因。

您确定不应该使用UIView自己编写的自定义子类吗?

如果不是,为什么你想设置delegateUIView您实际上想做什么?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

UIView没有名为“ setTranslatesAutoresizingMaskIntoConstraints”的成员

swift uiview没有名为center的成员

没有名为的成员

“ UINavigationController?” 没有名为“ popToRootViewControllerAnimated”的成员

[AnyObject]?没有名为“下标”的成员

NSURLResponse没有名为allHeaderFields的成员

UIButton没有名为“ target”的成员

Swift'没有名为的成员'

AnyObject没有名为“ sort”的成员

斯威夫特:没有名为的成员

UIPanGestureRecognizer没有名为touchesBegan的成员

NSEntityDescription没有名为“ name”的成员

AnyObject?没有名为“ objectAtIndex”的成员

“ AppDelegate”没有名为“ managedObjectContext”的成员

“ PFObject”没有名为“下标”的成员

“ NSArray”没有名为“ append”的成员

'PFObject没有名为'subscript'的成员

Swift ViewController没有名为的成员

ViewController没有名为tipCalc的成员

“ PFUser”没有名为“下标”的成员

有东西吗?没有名为“ removeAtIndex”的成员

字符串没有名为character的成员?

类sf :: RenderWindow'没有名为'clear'的成员

“ QWidget类”没有名为“ setFrameStyle”的成员

名称空间“ namespace”中没有名为“ name”的成员

“ GtkWidget {aka struct _GtkWidget}”没有名为“ window”的成员

Qlabel类没有名为“ ans”的成员

npm install失败,提示“没有名为isNearDeath的成员”

Swift-桥接头失败。“ *”没有名为“ *”的成员