如何调用方法“willDisplayFooterView”在表格视图菜单中? [英] How to call a method "willDisplayFooterView" during Table View cusomization?

查看:429
本文介绍了如何调用方法“willDisplayFooterView”在表格视图菜单中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用这些方法:

   - (void)tableView:(UITableView *)tableView willDisplayHeaderView :( UIView * )视图forSection:(NSInteger)节NS_AVAILABLE_IOS(6_0); 
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)视图forSection:(NSInteger)部分NS_AVAILABLE_IOS(6_0);

但我不能!根本没有反应。我正在测试模拟器iOS 6.0

   - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)视图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)];
[查看addSubview:imageView];


- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)视图forSection:(NSInteger)节
{
DLog(@ );
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)];
[查看addSubview:imageView];
}

其他代理方法工作正常!

解决方案

你需要在视图控制器中评论这个方法:
(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

现在的方法(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)



将被称为


I want to call these methods:

- (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);

but I can't! No reaction at all. I'm testing on simulator 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];
}

other delegate methods are working fine!

解决方案

you need just to comment this method in your view controller : (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ }

and now the method (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)

will be called

这篇关于如何调用方法“willDisplayFooterView”在表格视图菜单中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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