我有一个附加到TableViewCell类的自定义单元格,我在该自定义单元格中有一个按钮,我想要乳清我按下它会分割到另一个视图控制器的按钮,但是:
performSegueWithIdentifier(identifier: String, sender: AnyObject?)
Run Code Online (Sandbox Code Playgroud)
功能无法识别,如何解决?
编辑:

mus*_*afa 19
-performSegueWithIdentifier:方法声明在UIViewController.所以你不能只在UITableViewCell子类中调用它.
在-tableView:cellForRowAtIndexpath:方法中创建单元格时,可以向该按钮添加操作.然后你可以-performSegueWithIdentifier:在那个动作方法中调用方法.这是假设我们在UITableViewController子类中的示例:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.button.addTarget(self, action: "someAction", forControlEvents: .TouchUpInside)
return cell
}
Run Code Online (Sandbox Code Playgroud)
这是行动方法:
func someAction() {
self.performSegueWithIdentifier("moveToView", sender: self)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6875 次 |
| 最近记录: |