Skip to content

Commit

Permalink
pageView
Browse files Browse the repository at this point in the history
  • Loading branch information
big show committed Oct 9, 2018
1 parent f87e100 commit ac24158
Show file tree
Hide file tree
Showing 96 changed files with 6,508 additions and 1,403 deletions.
442 changes: 380 additions & 62 deletions BigShow1949.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified BigShow1949/Classes/03 - ViewLayout(视图布局)/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -12,6 +16,7 @@
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="158" height="108"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ym3-z2-11m">
<rect key="frame" x="0.0" y="0.0" width="158" height="108"/>
Expand All @@ -20,9 +25,8 @@
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<color key="backgroundColor" red="0.0" green="0.73719776459999997" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.0" green="0.73719776459999997" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Ym3-z2-11m" secondAttribute="trailing" id="684-ap-NKv"/>
<constraint firstAttribute="bottom" secondItem="Ym3-z2-11m" secondAttribute="bottom" id="O9C-C4-anw"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ - (void)viewDidLoad {
// [self.collectionView addFooterWithCallback:^{
// NSLog(@"进入shang拉刷新状态");
// }];
[self.collectionView addHeaderWithTarget:self action:@selector(loadNewShops)];
[self.collectionView addFooterWithTarget:self action:@selector(loadMoreShops)];

self.collectionView.mj_header = [MJRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewShops)];
self.collectionView.mj_footer = [MJRefreshFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreShops)];
}

- (void)loadNewShops
Expand All @@ -69,7 +70,8 @@ - (void)loadNewShops
[self.collectionView reloadData];

// stop refresh
[self.collectionView headerEndRefreshing];
// [self.collectionView headerEndRefreshing];
[self.collectionView.mj_header endRefreshing];
});
}

Expand All @@ -81,7 +83,7 @@ - (void)loadMoreShops
[self.collectionView reloadData];

// stop refresh
[self.collectionView footerEndRefreshing];
[self.collectionView.mj_footer endRefreshing];
});
}

Expand Down Expand Up @@ -134,4 +136,4 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa



@end
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BaseCollectionViewVC.h
// YNPageViewController
//
// Created by ZYN on 2018/6/22.
// Copyright © 2018年 yongneng. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BaseCollectionViewVC : UIViewController

@property (nonatomic, strong) UICollectionView *collectionView;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//
// BaseCollectionViewVC.m
// YNPageViewController
//
// Created by ZYN on 2018/6/22.
// Copyright © 2018年 yongneng. All rights reserved.
//

#import "BaseCollectionViewVC.h"
#import "MJRefresh.h"
#define randomColor random(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
#define random(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
@interface BaseCollectionViewVC () <UICollectionViewDelegate, UICollectionViewDataSource>

@end

@implementation BaseCollectionViewVC

- (void)viewDidLoad {
[super viewDidLoad];

[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"id"];
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeaderID];
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:FooterID];
[self.view addSubview:self.collectionView];
[self addCollectionViewRefresh];
}

- (void)addCollectionViewRefresh {

__weak typeof (self) weakSelf = self;

self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.collectionView.mj_header endRefreshing];
});
}];

self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.collectionView.mj_footer endRefreshing];
});
}];
}

#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource

static NSString *HeaderID = @"header";

static NSString *FooterID = @"footer";

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
if (kind == UICollectionElementKindSectionHeader) {
UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeaderID forIndexPath:indexPath];
headerView.backgroundColor = randomColor;
return headerView;
} else { // 返回每一组的尾部视图
UICollectionReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:FooterID forIndexPath:indexPath];

footerView.backgroundColor = randomColor;
return footerView;
}
}

/// collectinView section header 在高版本存在系统BUG,需要设置zPosition = 0.0
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath {
view.layer.zPosition = 0.0;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
return (CGSize){YFScreen.width * 0.5, 22};
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
return (CGSize){YFScreen.width, 22};
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 3;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"id" forIndexPath:indexPath];
cell.backgroundColor = randomColor;
return cell;
}

- (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(100, 100);

_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor whiteColor];
}
return _collectionView;
}

- (void)dealloc {
NSLog(@"----- %@ delloc", self.class);
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// BasePageViewController.h
// YNPageViewController
//
// Created by ZYN on 2018/7/27.
// Copyright © 2018年 yongneng. All rights reserved.
// 中间层 - 为了演示API功能操作

#import "YNPageViewController.h"

@interface BasePageViewController : YNPageViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//
// BasePageViewController.m
// YNPageViewController
//
// Created by ZYN on 2018/7/27.
// Copyright © 2018年 yongneng. All rights reserved.
// 中间层 - 为了演示API功能操作

#import "BasePageViewController.h"
#import "BaseTableViewVC.h"
#import "UIView+YNPageExtend.h"
#import "FTPopOverMenu.h"
@interface BasePageViewController ()

@end

@implementation BasePageViewController

#pragma mark - Life Cycle
- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"功能操作"
style:UIBarButtonItemStylePlain
target:self action:@selector(rightButtonOnClick:event:)];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd));
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd));
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd));
}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd));
}

#pragma mark - Event Response

#pragma mark - --Notification Event Response

#pragma mark - --Button Event Response
- (void)rightButtonOnClick:(UIBarButtonItem *)item event:(UIEvent *)event {
__weak typeof(self) weakSelf = self;
[FTPopOverMenu showFromEvent:event withMenuArray:@[@"滚动到顶部",
@"更新菜单栏标题",
@"添加页面",
@"删除页面",
@"调整标题顺序",
@"reload",
@"刷新头部高度"] doneBlock:^(NSInteger selectedIndex) {
switch (selectedIndex) {
case 0:
{
[weakSelf scrollToTop:YES];
}
break;
case 1:
{
// [self updateMenuItemTitle:@"更新的标题" index:0];
[weakSelf updateMenuItemTitles:@[@"足球", @"棒球", @"篮球"]];
}
break;
case 2:
{
BaseTableViewVC *vc_1 = [[BaseTableViewVC alloc] init];
vc_1.cellTitle = @"插入页新面";
[weakSelf insertPageChildControllersWithTitles:@[@"插入页面"] controllers:@[vc_1] index:1];
}
break;
case 3:
{
// [self removePageControllerWithTitle:@"帽子"];
[weakSelf removePageControllerWithIndex:0];
}
break;
case 4:
{
[weakSelf replaceTitlesArrayForSort:@[@"帽子", @"衣服", @"鞋子"]];
}
break;
case 5:
{
weakSelf.titlesM = @[@"刷新页面", @"棒球", @"篮球"].mutableCopy;
weakSelf.config.menuHeight = 100;
weakSelf.pageIndex = 0;
[weakSelf reloadData];
}
break;
case 6:
{
weakSelf.headerView.yn_height = 300;
[weakSelf reloadData];
}
break;
}
} dismissBlock:nil];
}
#pragma mark - --Gesture Event Response

#pragma mark - System Delegate

#pragma mark - Custom Delegate

#pragma mark - Public Function

#pragma mark - Private Function

#pragma mark - Getter and Setter

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// BaseVC.h
// YNPageViewController
//
// Created by ZYN on 2018/6/22.
// Copyright © 2018年 yongneng. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BaseTableViewVC : UIViewController

@property (nonatomic, copy) NSString *cellTitle;

@property (nonatomic, strong) UITableView *tableView;

- (void)addTableViewRefresh;

@end
Loading

0 comments on commit ac24158

Please sign in to comment.