Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios “如何调用方法”;willDisplayFooterView";在表视图自定义期间?_Ios_Uitableview_Uiscrollview_Delegates_Ios6 - Fatal编程技术网

Ios “如何调用方法”;willDisplayFooterView";在表视图自定义期间?

Ios “如何调用方法”;willDisplayFooterView";在表视图自定义期间?,ios,uitableview,uiscrollview,delegates,ios6,Ios,Uitableview,Uiscrollview,Delegates,Ios6,我想调用这些方法: - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0); - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)secti

我想调用这些方法:

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
但我不能!完全没有反应。我正在模拟iOS 6.0上测试

- (void) tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    DLog(@"0>>");
    CGRect originalRect = view.frame;
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_top.png"]];
    [imageView setFrame:CGRectMake(0.0f, originalRect.size.height - imageView.frame.size.height, imageView.frame.size.width, imageView.frame.size.height)];
    [view addSubview:imageView];
}

- (void) tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section
{
     DLog(@"0>f>");
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_bottom.png"]];
    [imageView setFrame:CGRectMake(0.0f, 0.0f, imageView.frame.size.width, imageView.frame.size.height)];
    [view addSubview:imageView];
}

其他委托方法工作正常

您不能调用这些方法。表视图将调用这些方法(如果存在)的实现,让您知道它即将显示页眉或页脚视图


这些是您提供的可选方法。表视图不提供它们。

您只需在视图控制器中对该方法进行注释: (UIView*)表格视图:(UITableView*)表格视图用于标题部分:(NSInteger)部分{ }

现在,方法(void)tableView:(UITableView*)tableView将显示headerview:(UIView*)view for section:(NSInteger)


将被称为

此答案适用于Swift

供您实施以下方法:

func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {}
func tableView(_ tableView: UITableView, didEndDisplayingFooterView view: UIView, forSection section: Int) {}
有必要实现另外两种方法,将视图页脚添加到tableView中

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {}

表视图不调用它们,它们将仅在iOS 6.0或更高版本下调用,并且仅当您还实现了其他页眉/页脚标题/视图方法时才会调用。如果您提供的是页眉或页脚,则不需要调用它们。它要复杂得多,但我现在可以以任何方式自定义它。它不适合任何情况,但我的解决方案非常适合我当前的项目。当它是一个分组的tableview时,我遇到了同样的问题,它只有在它是一个普通的tableview时才有效,而且我根本没有实现ViewForHeaderSection。