小编Eug*_*ock的帖子

Swift-自定义UITableViewCell委托给UIViewController只有一个协议可以工作

在应用程序中,我有自己的UIViewController符合的自定义协议.我有一个自定义的tableViewCell类,并在那里有UIImageView和UITextView.我在出列后将单元格的委托设置为UIViewController.但是,只有一个自定义协议进行回调(imagepicker协议).

protocol customProtocol1{
    func pickImage(myInt: Int)
}
protocol customProtocol2{
    func protocol2 (myInt: Int)
}

class controller1: UIViewController, UITableViewDelegate, customProtocol1, customProtocol2  {
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section:Int) -> Int {
        return 3
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
        let cell = tableView.dequeReusableCellWithIdentifier("customCell",    forIndexPath: indexPath) as! CustomTableCellClass
        cell.delegate = self
        return cell
   }
    func pickImage ( myInt: Int){
        print("This line prints")
   }

   func protocol2 (myInt: Int){
        print ("This line …
Run Code Online (Sandbox Code Playgroud)

uitableview uiviewcontroller ios swift

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

标签 统计

ios ×1

swift ×1

uitableview ×1

uiviewcontroller ×1