1.获取路径
NSString *path=[[NSBundle mainBundle]pathForResource:@"文件名"ofType:@"文件后缀名"];
2.手写代理
step1.被代理对象:
1.声明协议
@class LoadMoreView;
@protocol LoadViewDelegate <NSObject>
@optional
-(void)loadMoreViewBtnDidLoad:(LoadMoreView *)loadMoreView;
@end
2.提供一个代理属性
@property(nonatomic,weak)id<LoadViewDelegate>delegate;
3.当监听到事件触发的时候执行的代理方法
if([self.delegate respondsToSelector:@selector(loadMoreViewBtnDidLoad:)]){
[self.delegate loadMoreViewBtnDidLoad:self];
}
step2.代理对象
1.遵循协议
@interface ViewController ()<UITableViewDataSource,LoadViewDelegate>
2.设置代理
loadMoreView.delegate=self;
3.实现代理方法
-(void)loadMoreViewBtnDidLoad:(LoadMoreView *)loadMoreView{
HeroModel *model=[[HeroModel alloc]init];
model.icon=@"231871561051.png";
model.name=@"最后一只恐龙.纳尔";
model.intro=@"这是一个上单英雄,AD";
[self.heroes addObject:model];
[self.tableView reloadData];
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:self.heroes.count-1 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:true];
}