Swift对registerclass的模糊​​使用 [英] ambiguous use of registerclass with Swift

查看:79
本文介绍了Swift对registerclass的模糊​​使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tableView.RegisterClass( cellClass: CustomTableViewCell.self,
                         forCellReuseIdentifier: "CustomCell"
                         )

CustomTableViewCell是Objective-c类,已包含在桥接头文件中.

CustomTableViewCell is an Objective-c class and it's been included in a bridging header.

我不知道这是怎么回事?谁能告诉我这个错误是什么意思?

I couldn't figure out what's wrong with it? Can anyone tell me what does that error mean?

推荐答案

您对registerClass的调用具有第一个参数的参数名称(cellClass).在Swift中,第一个参数名称被省略.

Your call to registerClass has a parameter name (cellClass) for the first parameter. In Swift, the first parameter name is omitted.

tableView.registerClass(CustomTableViewCell.self, 
                        forCellReuseIdentifier: "CustomCell")

该错误表明使用registerClass的原因是因为编译器无法告诉您您要调用的是哪一个. UITableView上有两种registerClass方法:

The reason the error says ambiguous use of registerClass is because the compiler can't tell which one you are trying to call. There are two registerClass methods on UITableView:

func registerClass(cellClass: AnyClass, forCellReuseIdentifier identifier: String)
func registerClass(aClass: AnyClass, forHeaderFooterViewReuseIdentifier identifier: String)

您的通话与以上任何一项都不匹配,因此模棱两可.

Your call doesn't match either of these, therefore it's ambiguous.

这篇关于Swift对registerclass的模糊​​使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆