IOS学习笔记(六)

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];
}
3.手写cell且不同高度
step1.创建一个自定义的cell,继承UITableView,重写initWithStyle方法,在这个方法中添加所有可能出现的子控件
step2.创建一个frame模型,在这个模型中拥有一个数据模型,重写数据模型的set方法,计算各个子控件的frame以及cell的高度
step3.cell拥有一个frame模型,重写模型的set方法,设置各个控件frame以及数据
step4.控制器记录一个装载frame模型的数组,通过这个数组给数据源方法赋值,以及设置cell的高度
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值