Ios 为什么不同表视图控制器中的titleForHeaderInstruction方法不起作用?
为什么不同表视图控制器中的Ios 为什么不同表视图控制器中的titleForHeaderInstruction方法不起作用?,ios,iphone,swift,uitableview,Ios,Iphone,Swift,Uitableview,为什么不同表视图控制器中的titleForheaderInsection方法不起作用 我在一个故事板中为我的应用程序创建了两个具有不同功能的表视图控制器,一个是SettingStableViewControllR,一个是CitylistTableViewControllR,它们应该具有不同的节标题 tableView:titleForHeaderInSection方法用于命名节标题,但不幸的是只有SettingsTableViewControlelr中的方法在iOS simulator中正确出现
titleForheaderInsection
方法不起作用
我在一个故事板中为我的应用程序创建了两个具有不同功能的表视图控制器,一个是SettingStableViewControllR
,一个是CitylistTableViewControllR
,它们应该具有不同的节标题
tableView:titleForHeaderInSection
方法用于命名节标题,但不幸的是只有SettingsTableViewControlelr
中的方法在iOS simulator中正确出现,但CitylistTableViewControlelr
中的方法不起作用,我在tableView:titleForHeaderInSection
方法上放置了一个断点,发现该方法甚至不能在citylistableviewcontrolelr
中调用。下面是我的代码:
设置StableViewer控制器
城市列表视图控件
我的问题是:
tableView:titleForHeaderInSection
方法不能在CityListTableViewController
中调用李>
看看两者之间的区别: 在调用它的第一个视图控制器中,函数声明如下:
override func tableView(tableView: UITableView, titleForHeaderInSection section:Int) -> String? {
switch section{
func tableView(tableView: UITableView, titleForheaderInsection section: Int) -> String? {
switch section {
而在一个没有被称为的例子中,它是这样声明的:
override func tableView(tableView: UITableView, titleForHeaderInSection section:Int) -> String? {
switch section{
func tableView(tableView: UITableView, titleForheaderInsection section: Int) -> String? {
switch section {
您缺少覆盖声明。另外,您在第二个声明中没有大写“header”(感谢您指出Jesper)。感谢您的回答。我尝试在方法之前添加“override”关键字,但编译器报告错误显示“方法不重写其超类中的任何方法”。您键入了它
titleForheaderInsection
,而不是titleForheaderInsection
。选择器区分大小写。非常感谢,@Jesper&Yarneo。这就是造成问题的原因。