类型“Int”不符合协议“BooleanType”

2024-04-14

我对这个声明做错了什么? currentRow 是一个 NSIndexPath

  override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    if indexPath.row && currentRow?.row == 5 {
        return  300
    }
    return 70

我得到的错误是:

类型“Int”不符合协议“BooleanType”


如果你想检查你的 currentRow 和 indexPath 是否都是5你不能使用这样的 if 语句。将其更改为:

 if indexPath.row == currentRow?.row  && currentRow == 5 {

or:

 if indexPath.row == 5  && currentRow?.row == 5 {

如果您想检查是否indexPath is nil检查indexPath是否是0

if indexPath.row != 0 && currentRow?.row == 5 {
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

类型“Int”不符合协议“BooleanType” 的相关文章

随机推荐