美文网首页
IOS 设置tableView的footerView

IOS 设置tableView的footerView

作者: Fat_Blog | 来源:发表于2020-07-29 10:52 被阅读0次

效果图

image.png

代码实现

首先需要新建一个类来存放这个底部view(方法多样,这只是我的做法)

image.png

介绍一下单独创造一个xib的做法(因为有些类创建时是不能同时创建xib的,就像我上面那个图的类是继承于UIView,需要自己再创建一个xib


image.png

创建完之后记得要设置这个xib从属于哪个类


image.png
.h文件
#import <UIKit/UIKit.h>

@interface upLoaddata : UIView
+(instancetype)setfooter;
@end

.m文件
#import "upLoaddata.h"

@implementation upLoaddata

+(instancetype)setfooter
{
    return [[[NSBundle mainBundle] loadNibNamed:@"upLoaddata" owner:nil options:nil] lastObject];
}
//这是设置了view的点击事件
- (IBAction)button:(UIButton *)sender {
    //发布通知来监听按钮的点击
    //发布通知
    NSNotification *post = [NSNotification notificationWithName:@"dowmloadmore" object:nil];
    [[NSNotificationCenter defaultCenter]postNotification:post];
}

@end

调用的操作
记得先导入这个类的头文件
self.tableView.tableFooterView = [upLoaddata setfooter];

相关文章

网友评论

      本文标题:IOS 设置tableView的footerView

      本文链接:https://www.haomeiwen.com/subject/uchhrktx.html