16-ios_Demo-4

7.0

HomeView

成员变量

@property(nonatomic,strong)IBOutlet UICollectionView *collectionView;   最外层的view
@property(nonatomic,strong)IBOutlet UIButton *liveBnt;                  直播间
@property(nonatomic,strong)IBOutlet UIButton *dayQuanBnt;               每日发圈
@property(nonatomic,strong)IBOutlet UIButton *toTopBnt;                 回到顶部
@property(nonatomic,strong)IBOutlet NSLayoutConstraint *bomSpacing;     一个间距
@property(nonatomic,strong)IBOutlet NSLayoutConstraint *quanbomSpacing; 一个间距
@property(nonatomic,weak) BaseViewController *VC;                       vc
@property(nonatomic,strong)NSMutableArray* goodsDatas;                  商品bean
@property(nonatomic,strong)MainData* datas;                             主要的bean
@property(nonatomic,assign)int curPage;                                 下部的page

Func:

1.-(void)initDatas:(id)data vc:(BaseViewController*)vc

-->注入各种bean;刷新一些view

2.-(void)initViews(初始化HomeView)

-->设置下拉刷新();调接口;设置上拉刷新更新数据

3.-(void)beginRefresh

-->开始下拉刷新

4.-(void)updateLogin

-->在登录以后,刷新首页的显示数据,up_button,live等view的显示问题

5.-(IBAction)toTop:(id)sender

-->回到顶部

6.-(IBAction)toDayQuan:(id)sender

-->每日发圈

7.-(IBAction)toLive:(id)sender

-->跳转到每日发圈

8.-(void)newGoods:(NSArray*)datas

-->跳转到每日发圈

9.-(void)newGoods:(NSArray*)datas

-->类似android里面的那些方法,更新下数据,然后reload

10.-(void)addGoods:(NSArray*)datas

-->类似android里面的那些方法,添加数据,然后reload

注:

     上面全部都是自写的方法,而下面,有很多都是代理方法&collection的重写方法

11.- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView

-->返回seciton的个数,这里的section就是分区,每个分区都可以设置a pair of header&footer

12.- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

-->返回seciton里面item的个数,自然也就是data的个数

13.- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section

-->给这个section的头部设置尺寸:宽高

14.- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

-->返回section里面的item的尺寸:高宽

15.- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

-->创建UICollectionViewCell,然后根绝indexPath得到相应的view,绑数据,然后返回

16.- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath

-->之前设置了头部的尺寸,这里,要把头部view返回去,这里header和footer都是调的同一方法,通过kind来返回相应的view

17.- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

-->选中某个item, 让其不要在被选择的状态,因为之前已经有设置监听了,这里取消选定就可以

18.-(void)scrollViewDidScroll:(UIScrollView *)scrollView

-->监听scrollView的滑动情况,然后判断是否出现那个返回顶端那个小view

19.- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

-->滚动完毕以后执行某方法

小结:

          HomeViewController是一个Navigation类的vc,因为这样才可以push到其他的vc

这个vc有:TopLayoutGuide + GuideLayoutGuide + HomeView + NavigationItem

这里要注意的是,这些view其实都必须要有NavigationItem,只不过你可以改造,首页的把NavigationItem改造成搜索,其他页的改成标题之类的,这样可以随便push。

然后这里的HomeView = CollectionView + some buttons

CollectionView里面只有一个section,这个section的body就是各种重写方法写出来的“多data商品listview”

其头部就是:各种Banner + kqData + Adzone + bkData等

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值