Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios “快速附加参数”;宽度“;在CGRect中调用_Ios_Swift_Uibutton - Fatal编程技术网

Ios “快速附加参数”;宽度“;在CGRect中调用

Ios “快速附加参数”;宽度“;在CGRect中调用,ios,swift,uibutton,Ios,Swift,Uibutton,我试图在代码中添加几个按钮 我得到一个错误“额外参数”宽度“在调用中” 让yPos=txt.frame.origin.y+txt.frame.height 因为我犯了一个错误,我不得不把所有的参数都转换成CGFloat for i in 0...2 { let yt : CGFloat = CGFloat(i*40) + yPos //let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100,

我试图在代码中添加几个按钮 我得到一个错误“额外参数”宽度“在调用中”

让yPos=txt.frame.origin.y+txt.frame.height

因为我犯了一个错误,我不得不把所有的参数都转换成CGFloat

       for i in 0...2 {
        let yt : CGFloat = CGFloat(i*40) + yPos
        //let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
        var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
        b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
        b.backgroundColor = UIColor.blackColor()
        b.tag = i
        self.addSubview(b)
    }

我的错误是我不得不把所有的论据都交给我

       for i in 0...2 {
        let yt : CGFloat = CGFloat(i*40) + yPos
        //let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
        var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
        b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
        b.backgroundColor = UIColor.blackColor()
        b.tag = i
        self.addSubview(b)
    }

我的错误是我不得不把所有的论据都交给我

       for i in 0...2 {
        let yt : CGFloat = CGFloat(i*40) + yPos
        //let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
        var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
        b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
        b.backgroundColor = UIColor.blackColor()
        b.tag = i
        self.addSubview(b)
    }

我的错误是我不得不把所有的论据都交给我

       for i in 0...2 {
        let yt : CGFloat = CGFloat(i*40) + yPos
        //let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
        var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
        b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
        b.backgroundColor = UIColor.blackColor()
        b.tag = i
        self.addSubview(b)
    }