text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```objective-c // // YFTableViewDelAllCell.m // BigShow1949 // // Created by zhht01 on 16/3/1. // #import "YFTableViewDelAllCell.h" @implementation YFTableViewDelAllCell + (instancetype)cellWithtableView:(UITableView *)tableView { static NSString *ID = @"YFChargingPileCell"; YFTableViewDelAllCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (cell == nil) { cell = [[YFTableViewDelAllCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; } cell.backgroundColor = [UIColor clearColor]; // cell.selectionStyle = UITableViewCellSelectionStyleGray; return cell; } #pragma mark - - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // [self makeView]; } return self; } - (void)makeView { UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 20)]; btn1.backgroundColor = [UIColor redColor]; [self.contentView addSubview:btn1]; UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 25, 50, 20)]; btn2.backgroundColor = [UIColor greenColor]; [self.contentView addSubview:btn2]; UIButton *btn3 = [[UIButton alloc] initWithFrame:CGRectMake(300, 0, 20, 20)]; btn3.backgroundColor = [UIColor blueColor]; [self.contentView addSubview:btn3]; // self.frame = CGRectMake(0, 0, YFScreen.width, 130); } //- (void)layoutSubviews { // // [super layoutSubviews]; // if (self.selected) { // self.imageView.backgroundColor = [UIColor clearColor]; // } //} //-(void)layoutSubviews //{ // [super layoutSubviews]; // // if (self.selected) // { // self.cellBackImageView.backgroundColor = [UIColor clearColor]; // // self.cellRockImageView.backgroundColor = [UIColor clearColor]; // // } // // //} @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFTableViewDelAllCell.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
471
```objective-c // // YFBottomEditView.h // SmartingPark // // Created by WangMengqi on 15/8/26. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @protocol YFBottomEditViewDelegate; @interface YFBottomEditView : NSObject @property (nonatomic, strong) UIButton *deleteBtn; @property (nonatomic, assign) id <YFBottomEditViewDelegate> dataSource; /** * YFBottomEditView , */ @property(nullable, nonatomic,copy) UIColor *backgroundColor; /** * bottomView * * @param animated () */ - (void)show; - (void)showWithAnimated:(BOOL)animated; /** * bottomView * * @param animated () */ - (void)hidden; - (void)hiddenWithAnimated:(BOOL)animated; @end @protocol YFBottomEditViewDelegate<NSObject> @required /** * */ - (void)deleteSelectItem; @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFBottomEditView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
204
```objective-c // // YFBottomEditView.m // SmartingPark // // Created by WangMengqi on 15/8/26. // #define YFScreen [UIScreen mainScreen].bounds.size #import "YFBottomEditView.h" @interface YFBottomEditView ()<UIAlertViewDelegate> @property (nonatomic, weak) UIView *bottomView; @end @implementation YFBottomEditView - (void)show { [self showWithAnimated:YES]; } - (void)hidden { [self hiddenWithAnimated:YES]; } - (void)showWithAnimated:(BOOL)animated { NSTimeInterval animatedTime = animated ? 0.5 : 0.0; [UIView animateWithDuration:animatedTime animations:^{ CGRect tempFrame = self.bottomView.frame; tempFrame.origin.y = YFScreen.height - 44; self.bottomView.frame = tempFrame; }]; } - (void)hiddenWithAnimated:(BOOL)animated { NSTimeInterval animatedTime = animated ? 0.5 : 0.0; [UIView animateWithDuration:animatedTime animations:^{ CGRect tempFrame = self.bottomView.frame; tempFrame.origin.y = YFScreen.height; self.bottomView.frame = tempFrame; }completion:^(BOOL finished) { // [self.bottomView removeFromSuperview]; }]; } #pragma mark - - (UIView *)bottomView { if (!_bottomView) { // bottomView UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, YFScreen.height, YFScreen.width, 60)]; bottomView.backgroundColor = [UIColor whiteColor]; UIWindow *window = [UIApplication sharedApplication].keyWindow; [window addSubview:bottomView]; _bottomView = bottomView; // UIButton *delete = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, bottomView.frame.size.width, bottomView.frame.size.height)]; self.deleteBtn = delete; [delete setTitle:@"" forState:UIControlStateNormal]; [delete setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; [delete setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled]; [delete addTarget:self action:@selector(deleteBtnClick:) forControlEvents:UIControlEventTouchUpInside]; delete.titleLabel.font = [UIFont systemFontOfSize:18]; // self.deleteBtn.enabled = NO; [bottomView addSubview:delete]; } return _bottomView; } - (void)setBackgroundColor:(UIColor *)backgroundColor { self.bottomView.backgroundColor = backgroundColor; } #pragma mark - private method - (void)deleteBtnClick:(UIButton *)btn { if ([self.dataSource respondsToSelector:@selector(deleteSelectItem)]) { [self.dataSource deleteSelectItem]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFBottomEditView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
559
```objective-c // // YFTableViewDelAll.h // BigShow1949 // // Created by zhht01 on 16/1/15. // #import <UIKit/UIKit.h> @interface YFTableViewDelAll : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFTableViewDelAll.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
52
```objective-c // // YFTableViewDelAllCell.h // BigShow1949 // // Created by zhht01 on 16/3/1. // #import <UIKit/UIKit.h> @interface YFTableViewDelAllCell : UITableViewCell + (instancetype)cellWithtableView:(UITableView *)tableView; @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFTableViewDelAllCell.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
66
```objective-c // // YFImitateAppViewController.h // BigShow1949 // // Created by WangMengqi on 15/9/2. // #import <UIKit/UIKit.h> @interface YFImitateAppViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/YFImitateAppViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
57
```objective-c // // YFImitateAppViewController.m // BigShow1949 // // Created by WangMengqi on 15/9/2. // #import "YFImitateAppViewController.h" @interface YFImitateAppViewController () @end @implementation YFImitateAppViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"",@"YFNeteaseViewController"], @[@"",@"YFWeChatViewController"], @[@"",@"YFApeExamViewController"], @[@"",@"YFAliViewController"],]]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/YFImitateAppViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
125
```objective-c // // ViewController.m // talbeViewDeleteTEST // // Created by zhht01 on 16/1/14. // #import "YFTableViewDelAll.h" #import "YFBottomEditView.h" #import "YFTableViewDelAllCell.h" @interface YFTableViewDelAll ()<UITableViewDataSource, UITableViewDelegate,YFBottomEditViewDelegate> @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *datas; // view @property (nonatomic, strong) YFBottomEditView *bottomEditView; // @property (nonatomic, strong) NSMutableDictionary *deletDic; @end @implementation YFTableViewDelAll - (void)viewDidLoad { [super viewDidLoad]; self.title = @""; _deletDic = [NSMutableDictionary dictionary]; [self.view addSubview:self.tableView]; [self setupNav]; } - (void)setupNav { self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(editionRemove:)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(backOrSelectAll:)]; } - (void)editionRemove:(UIBarButtonItem *)button { if ([button.title isEqual:@""]) { [button setTitle:@""]; self.navigationItem.leftBarButtonItem.title = @""; [self.deletDic removeAllObjects]; [self.bottomEditView show]; [self.tableView setEditing:YES animated:YES]; } else if ([button.title isEqual:@""]) { [button setTitle:@""]; self.navigationItem.leftBarButtonItem.title = @""; [self.bottomEditView hidden]; [self.tableView setEditing:NO animated:YES]; } } - (void)backOrSelectAll:(UIBarButtonItem *)button { if ([button.title isEqual:@""]) { [self.navigationController popViewControllerAnimated:YES]; }else if ([button.title isEqual:@""]) { button.title = @""; // [self.datas enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { NSIndexPath *path = [NSIndexPath indexPathForRow:idx inSection:0]; [self.deletDic setObject:self.datas[path.row] forKey:path]; [self.tableView selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionNone]; }]; // "" self.bottomEditView.deleteBtn.enabled = YES; }else if ([button.title isEqual:@""]) { button.title = @""; // [self.deletDic removeAllObjects]; [self.datas enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { NSIndexPath *path = [NSIndexPath indexPathForRow:idx inSection:0]; [self.tableView deselectRowAtIndexPath:path animated:YES]; }]; // "" self.bottomEditView.deleteBtn.enabled = NO; } } #pragma mark - UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.datas.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { YFTableViewDelAllCell *cell = [YFTableViewDelAllCell cellWithtableView:tableView]; cell.textLabel.text = self.datas[indexPath.row]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 130; } #pragma mark - UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([self.navigationItem.rightBarButtonItem.title isEqual:@""]) { // [self.deletDic setObject:self.datas[indexPath.row] forKey:indexPath]; // if (self.deletDic.count == self.datas.count) { self.navigationItem.leftBarButtonItem.title = @""; } // "" self.bottomEditView.deleteBtn.enabled = YES; } NSLog(@"subviewss = %@", tableView.subviews); // [tableView deselectRowAtIndexPath:indexPath animated:YES]; // ,, } - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { if ([self.navigationItem.rightBarButtonItem.title isEqual:@""]) { // [self.deletDic removeObjectForKey:indexPath]; self.navigationItem.leftBarButtonItem.title = @""; // "" NSArray *deleDatas = [NSArray arrayWithArray:[self.deletDic allValues]]; if (deleDatas.count == 0) { self.bottomEditView.deleteBtn.enabled = NO; } } NSLog(@"subviewss = %@", tableView.subviews); } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;; } #pragma mark - YFBottomEditViewDelegate - (void)deleteSelectItem { // NSArray *indexPathsText =[self.tableView indexPathsForSelectedRows]; NSLog(@"indexPathsText = %@", indexPathsText); // NSArray *deleDatas = [NSArray arrayWithArray:[self.deletDic allValues]]; NSArray *indexPaths = [NSArray arrayWithArray:[self.deletDic allKeys]]; [self.datas removeObjectsInArray:deleDatas]; [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationLeft]; [self.deletDic removeAllObjects]; [self.tableView reloadData]; } #pragma mark - - (YFBottomEditView *)bottomEditView { if (_bottomEditView == nil) { _bottomEditView = [[YFBottomEditView alloc] init]; _bottomEditView.backgroundColor = [UIColor lightGrayColor];; _bottomEditView.dataSource = self; } return _bottomEditView; } - (NSMutableArray *)datas { if (!_datas) { NSMutableArray *arr = [NSMutableArray arrayWithArray:@[@"123",@"234",@"345"]]; _datas = arr; } return _datas; } - (UITableView *)tableView { if (_tableView == nil) { CGFloat app_width = [UIScreen mainScreen].bounds.size.width; CGFloat app_height = [UIScreen mainScreen].bounds.size.height; _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, app_width, app_height) style:UITableViewStylePlain]; _tableView.dataSource = self; _tableView.delegate = self; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.allowsSelectionDuringEditing = YES; } return _tableView; } @end ```
/content/code_sandbox/BigShow1949/Classes/08 - UIKit/UIScrollView/UITalbeView全选删除/YFTableViewDelAll.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,350
```objective-c // // YFNeteaseViewController.h // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "BaseTableViewController.h" @interface YFNeteaseViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/网易/YFNeteaseViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
55
```objective-c // // YFAliViewController.m // BigShow1949 // // Created by apple on 16/8/20. // #import "YFAliViewController.h" @interface YFAliViewController () @end @implementation YFAliViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@"",@"YFAliNumberViewController"]]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/阿里巴巴/YFAliViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
84
```objective-c // // YFNeteaseViewController.m // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "YFNeteaseViewController.h" @interface YFNeteaseViewController () @end @implementation YFNeteaseViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"1",@"YFNeteaseHomeViewController"]]]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/网易/YFNeteaseViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
93
```objective-c // // YFAliViewController.h // BigShow1949 // // Created by apple on 16/8/20. // #import "BaseTableViewController.h" @interface YFAliViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/阿里巴巴/YFAliViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
51
```objective-c // // YFApeExamViewController.h // BigShow1949 // // Created by zhht01 on 16/3/30. // #import "BaseTableViewController.h" @interface YFApeExamViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/YFApeExamViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
55
```objective-c // // YFApeExamViewController.m // BigShow1949 // // Created by zhht01 on 16/3/30. // #import "YFApeExamViewController.h" @interface YFApeExamViewController () @end @implementation YFApeExamViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"",@"YFAnswerViewController"], @[@"cell",@"YFTableNodeViewController"], @[@"ape",@"YFBubbleMenuButtonViewController"], @[@"",@"JLHomePracticeViewController"],]]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/YFApeExamViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
123
```objective-c // // YFNode.h // YFTableNodeView // // Created by zhht01 on 16/3/28. // #import <Foundation/Foundation.h> @interface YFNode : NSObject @property (nonatomic) int nodeLevel;// @property (nonatomic) int nodeType;// @property (nonatomic) id nodeData;// @property (nonatomic) BOOL isExpanded;// @property (nonatomic,strong) NSMutableArray *sonNodes;// @property (nonatomic, assign) NSString *title; //@property (nonatomic, strong) NSMutableArray *dodes; - (instancetype)initWithDict:(NSDictionary *)dict; + (instancetype)nodeWithDict:(NSDictionary *)dict; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/TableNodeView/YFNode.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
140
```objective-c // // ViewController.h // YFTableNodeView // // Created by zhht01 on 16/3/28. // #import <UIKit/UIKit.h> @interface YFTableNodeViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/TableNodeView/YFTableNodeViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
49
```objective-c // // YFNode.m // YFTableNodeView // // Created by zhht01 on 16/3/28. // #import "YFNode.h" @implementation YFNode - (instancetype)initWithDict:(NSDictionary *)dict { if (self = [super init]) { // [self setValuesForKeysWithDictionary:dict]; self.title = dict[@"title"]; self.sonNodes = dict[@"sonNode"]; self.isExpanded = NO; // NSLog(@"title = %@", self.title); // NSLog(@"sonNodes = %@", self.sonNodes); // 2. friends NSMutableArray *tempArray = [NSMutableArray array]; for (NSDictionary *dict in self.sonNodes) { YFNode *sonNode = [YFNode nodeWithDict:dict]; [tempArray addObject:sonNode]; } self.sonNodes = tempArray; } return self; } + (instancetype)nodeWithDict:(NSDictionary *)dict { return [[self alloc] initWithDict:dict]; } //- (NSMutableArray *)sonNodes { // // if (!_sonNodes) { // _sonNodes = [NSMutableArray array]; // } // return _sonNodes; //} @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/TableNodeView/YFNode.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
272
```objective-c // // JLHomePracticeSubjectsCollectionViewCell.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeSubjectsCollectionViewCell.h" @interface JLHomePracticeSubjectsCollectionViewCell () @property (nonatomic, strong, nonnull) UILabel *label; @end @implementation JLHomePracticeSubjectsCollectionViewCell - (instancetype) initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 20)]; _label.center = self.contentView.center; [self.contentView addSubview:_label]; } return self; } - (void)bindDataWithViewModel:(JLHomePracticeSubjectsCollectionCellViewModel *)viewModel { [_label setText:viewModel.title]; [_label setTextColor:viewModel.titleColor]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeSubjectsCollectionViewCell.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
189
```objective-c // // JLHomePracticeActivityView.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> #import "JLHomePracticeSubjectsViewModel.h" @interface JLHomePracticeActivityView : UIView @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeActivityView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
63
```objective-c // // JLHomePracticeBannerView.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> @interface JLHomePracticeBannerView : UIView @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeBannerView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
53
```objective-c // // JLHomePracticeActivityView.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeActivityView.h" @implementation JLHomePracticeActivityView - (instancetype)init { self = [super init]; if (self) { self.backgroundColor = [UIColor redColor]; } return self; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeActivityView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
90
```objective-c // // JLHomePracticeBannerView.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeBannerView.h" @implementation JLHomePracticeBannerView - (instancetype)init { self = [super init]; if (self) { self.backgroundColor = [UIColor blueColor]; } return self; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeBannerView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
90
```objective-c // // ViewController.m // YFTableNodeView // // Created by zhht01 on 16/3/28. // #import "YFTableNodeViewController.h" #import "YFNode.h" @interface YFTableNodeViewController ()<UITableViewDelegate,UITableViewDataSource> { NSInteger _count; // } @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *dataArray; // @property (nonatomic, strong) NSMutableArray *displayArray; // @end @implementation YFTableNodeViewController - (void)viewDidLoad { [super viewDidLoad]; self.displayArray = [NSMutableArray array]; self.dataArray = [NSMutableArray array]; // [self loadData]; [self reloadDataForDisplayArray]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)]; self.tableView.delegate = self; self.tableView.dataSource = self; [self.view addSubview:self.tableView]; } - (void)loadData { /* cell , self.dataArray ,title // plist NSArray *dictArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"node.plist" ofType:nil]]; for (NSDictionary *dict in dictArray) { YFNode *node = [YFNode nodeWithDict:dict]; [self.dataArray addObject:node]; } // NSLog(@"friends.plist = %@", dictArray); NSLog(@"dataArray = %@", self.dataArray); for (YFNode *node in self.dataArray) { NSLog(@"node.title = %@", node.title); for (YFNode *sonNode in node.sonNodes) { NSLog(@"sonNode.title = %@", sonNode.title); } } // */ //* YFNode *node0 = [[YFNode alloc] init]; node0.isExpanded = NO; node0.title = @""; YFNode *node1 = [[YFNode alloc] init]; node1.isExpanded = NO; node1.title = @""; YFNode *node2 = [[YFNode alloc] init]; node2.isExpanded = NO; node2.title = @""; YFNode *node3 = [[YFNode alloc] init]; node3.isExpanded = NO; node3.title = @""; YFNode *node4 = [[YFNode alloc] init]; node4.isExpanded = NO; node4.title = @""; YFNode *node5 = [[YFNode alloc] init]; node5.isExpanded = NO; node5.title = @""; YFNode *node6 = [[YFNode alloc] init]; node6.isExpanded = NO; node6.title = @""; YFNode *node7 = [[YFNode alloc] init]; node7.isExpanded = NO; node7.title = @""; node0.sonNodes = [NSMutableArray arrayWithObjects:node2, node3, nil]; node2.sonNodes = [NSMutableArray arrayWithObjects:node4, nil]; node3.sonNodes = [NSMutableArray arrayWithObjects:node5, node6, nil]; node5.sonNodes = [NSMutableArray arrayWithObjects:node7, nil]; self.dataArray = [NSMutableArray arrayWithObjects:node0,node1, nil]; for (YFNode *node in self.dataArray) { NSLog(@"node.title = %@", node.title); for (YFNode *sonNode in node.sonNodes) { NSLog(@"sonNode.title = %@", sonNode.title); } } //*/ } /*--------------------------------------- cell --------------------------------------- */ - (void)reloadDataForDisplayArray{ for (YFNode *node in self.dataArray) { [self.displayArray addObject:node]; if (node.isExpanded) { [self findSonNodes:node]; } } for (YFNode *node in self.displayArray) { NSLog(@"node.title = %@", node.title); for (YFNode *sonNode in node.sonNodes) { NSLog(@"sonNode.title = %@", sonNode.title); } } } - (void)findSonNodes:(YFNode *)node { for (YFNode *sonNode in node.sonNodes) { [self.displayArray addObject:sonNode]; [self findSonNodes:sonNode]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.displayArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { YFNode *node = self.displayArray[indexPath.row]; // for (YFNode *node in self.displayArray) { // NSLog(@"title = %@", node.title); // } NSLog(@"row = %zd", indexPath.row); UITableViewCell *cell = [[UITableViewCell alloc] init]; cell.textLabel.text = node.title; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { for (YFNode *node in self.displayArray) { NSLog(@"node.title = %@", node.title); for (YFNode *sonNode in node.sonNodes) { NSLog(@"sonNode.title = %@", sonNode); } } [self reloadData:indexPath.row]; // NSLog(@" displayArray = %@", self.displayArray); // for (YFNode *node in self.displayArray) { // NSLog(@"node.title = %@", node.title); // } } - (void)reloadData:(NSInteger)row { [self.displayArray removeAllObjects]; _count = 0; NSLog(@"count = %zd", self.dataArray.count); for (YFNode *node in self.dataArray) { // n0 n1 NSLog(@"node.title = %@, node = %p", node.title, node); // [self.displayArray addObject:node]; // n0 // if (_count == row) { // n0 node.isExpanded = !node.isExpanded; } _count++; // _cnt = 1 if (node.isExpanded) { // [self findSonNodes:node row:row]; } } [self.tableView reloadData]; } - (void)findSonNodes:(YFNode *)node row:(NSInteger)row{ // n0 0 for (YFNode *sonNode in node.sonNodes) { // n2 n3 NSLog(@"sonNode.title = %@", sonNode.title); NSLog(@"_count = %zd", _count); // [self.displayArray addObject:sonNode]; // n2 // if (_count == row) { // 1 != 0 sonNode.isExpanded = !sonNode.isExpanded; } _count++; // _cnt = 2; if (sonNode.isExpanded) { [self findSonNodes:sonNode row:row]; } } } #pragma mark - setter - (NSMutableArray *)displayArray { if (!_displayArray) { _displayArray = [NSMutableArray array]; } return _displayArray; } - (NSMutableArray *)dataArray { if (!_dataArray) { _dataArray = [NSMutableArray array]; } return _dataArray; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/TableNodeView/YFTableNodeViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,582
```objective-c // // APEHomePracticeSubjectsView.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> #import "JLHomePracticeSubjectsViewModel.h" @interface JLHomePracticeSubjectsView : UIView @property (nonatomic, strong, nullable, readonly) JLHomePracticeSubjectsViewModel *viewModel; - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsViewModel *)viewModel; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeSubjectsView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
100
```objective-c // // JLHomePracticeSubjectsCollectionViewCell.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> #import "JLHomePracticeSubjectsCollectionCellViewModel.h" @interface JLHomePracticeSubjectsCollectionViewCell : UICollectionViewCell - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModel; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeSubjectsCollectionViewCell.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
87
```objective-c // // JLHomePracticeSubjectsCollectionCellViewModel.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> #import "JLSubject.h" @interface JLHomePracticeSubjectsCollectionCellViewModel : NSObject @property (nonatomic, strong, nonnull) UIImage *image; @property (nonatomic, strong, nonnull) UIImage *highlightedImage; @property (nonatomic, strong, nonnull) NSString *title; @property (nonatomic, strong, nonnull) UIColor *titleColor; @property (nonatomic, strong, nonnull) UIColor *backgroundColor; + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelWithSubject:(nonnull JLSubject *)subject; + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelForMore; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewModel/JLHomePracticeSubjectsCollectionCellViewModel.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
167
```objective-c // // APEHomePracticeSubjectsView.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeSubjectsView.h" #import "JLHomePracticeSubjectsCollectionViewCell.h" @interface JLHomePracticeSubjectsView ()<UICollectionViewDataSource, UICollectionViewDelegate> @property (nonatomic, strong, nullable, readwrite) JLHomePracticeSubjectsViewModel *viewModel; @property (nonatomic, strong, nonnull) UICollectionView *collectionView; @end @implementation JLHomePracticeSubjectsView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, 200) collectionViewLayout:flowLayout]; _collectionView.delegate = self; _collectionView.dataSource = self; [_collectionView registerClass:[JLHomePracticeSubjectsCollectionViewCell class] forCellWithReuseIdentifier:@"Cell"]; [self addSubview:_collectionView]; } return self; } - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsViewModel *)viewModel { self.viewModel = viewModel; self.backgroundColor = viewModel.backgroundColor; [self.collectionView reloadData]; [self setNeedsUpdateConstraints]; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath: (NSIndexPath *)indexPath { JLHomePracticeSubjectsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; if (0 <= indexPath.row && indexPath.row < self.viewModel.cellViewModels.count) { JLHomePracticeSubjectsCollectionCellViewModel *vm = self.viewModel.cellViewModels[indexPath.row]; [cell bindDataWithViewModel:vm]; } return cell; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.viewModel.cellViewModels.count; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/View/JLHomePracticeSubjectsView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
398
```objective-c // // JLHomePracticeSubjectsViewModel.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <Foundation/Foundation.h> #import "JLHomePracticeSubjectsCollectionCellViewModel.h" #import "JLSubject.h" @interface JLHomePracticeSubjectsViewModel : NSObject @property (nonatomic, strong, nonnull) NSArray<JLHomePracticeSubjectsCollectionCellViewModel *> *cellViewModels; @property (nonatomic, strong, nonnull) UIColor *backgroundColor; + (nonnull JLHomePracticeSubjectsViewModel *)viewModelWithSubjects:(nonnull NSArray<JLSubject *> *)subjects; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewModel/JLHomePracticeSubjectsViewModel.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
134
```objective-c // // JLHomePracticeSubjectsCollectionCellViewModel.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeSubjectsCollectionCellViewModel.h" @implementation JLHomePracticeSubjectsCollectionCellViewModel + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelWithSubject:(nonnull JLSubject *)subject { JLHomePracticeSubjectsCollectionCellViewModel *vm = [[JLHomePracticeSubjectsCollectionCellViewModel alloc] init]; vm.backgroundColor = [UIColor whiteColor]; vm.title = subject.name; vm.titleColor = [UIColor greenColor]; return vm; } + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelForMore { JLHomePracticeSubjectsCollectionCellViewModel *vm = [[JLHomePracticeSubjectsCollectionCellViewModel alloc] init]; return vm; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewModel/JLHomePracticeSubjectsCollectionCellViewModel.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
180
```objective-c // // JLHomePracticeSubjectsViewModel.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeSubjectsViewModel.h" @implementation JLHomePracticeSubjectsViewModel + (nonnull JLHomePracticeSubjectsViewModel *)viewModelWithSubjects:(nonnull NSArray<JLSubject *> *)subjects { NSMutableArray<JLHomePracticeSubjectsCollectionCellViewModel *> *arr = [[NSMutableArray alloc] initWithCapacity:subjects.count]; [subjects enumerateObjectsUsingBlock:^(JLSubject * _Nonnull subject, NSUInteger idx, BOOL * _Nonnull stop) { [arr addObject:[JLHomePracticeSubjectsCollectionCellViewModel viewModelWithSubject:subject]]; }]; JLHomePracticeSubjectsViewModel *vm = [[JLHomePracticeSubjectsViewModel alloc] init]; vm.cellViewModels = [arr copy]; vm.backgroundColor = [UIColor whiteColor]; return vm; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewModel/JLHomePracticeSubjectsViewModel.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
193
```objective-c // // JLHomePracticeDataController.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeDataController.h" #import "JLSubjectDataController.h" @interface JLHomePracticeDataController () @property (nonatomic, strong, nonnull) JLSubjectDataController *subjectDataController; @end @implementation JLHomePracticeDataController - (instancetype)init { self = [super init]; if (self) { _subjectDataController = [[JLSubjectDataController alloc] init]; } return self; } - (void)requestSubjectDataWithCallback:(nonnull JLCompletionCallback)callback { [self.subjectDataController requestAllSubjects]; [self.subjectDataController requestUserSubjects]; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ callback(nil); }); } - (NSArray<JLSubject *> *)openSubjects { return self.subjectDataController.openSubjectsWithCurrentPhase ? : @[]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLHomePracticeDataController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
236
```objective-c // // JLHomePracticeDataController.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLBaseDataController.h" #import "JLSubject.h" @interface JLHomePracticeDataController : JLBaseDataController @property (nonatomic, strong, nullable) NSArray<JLSubject *> *openSubjects; - (void)requestSubjectDataWithCallback:(nonnull JLCompletionCallback)callback; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLHomePracticeDataController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
100
```objective-c // // JLBaseDataController.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <Foundation/Foundation.h> typedef void (^JLCompletionCallback)(NSError *); @interface JLBaseDataController : NSObject /** */ - (void)requestWithDataType:(NSString *)type; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLBaseDataController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
75
```objective-c // // JLSubjectDataController.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLSubjectDataController.h" #import "JLSubject.h" @interface JLSubjectDataController () @property (nonatomic, copy, nullable) NSArray<JLSubject *> *allSubjects; @property (nonatomic, copy, nullable) NSArray<JLSubject *> *userSubjects; @end @implementation JLSubjectDataController - (void)requestAllSubjects { // JLSubject *math = [[JLSubject alloc] init]; math.name = @""; math.id = @1; JLSubject *eng = [[JLSubject alloc] init]; eng.name = @""; eng.id = @2; JLSubject *chem = [[JLSubject alloc] init]; chem.name = @""; chem.id = @3; JLSubject *phy = [[JLSubject alloc] init]; phy.name = @""; phy.id = @4; _allSubjects = @[math, eng, chem, phy]; } - (void)requestUserSubjects { JLSubject *math = [[JLSubject alloc] init]; math.name = @""; math.id = @1; JLSubject *eng = [[JLSubject alloc] init]; eng.name = @""; eng.id = @2; JLSubject *chem = [[JLSubject alloc] init]; chem.name = @""; chem.id = @3; JLSubject *phy = [[JLSubject alloc] init]; phy.name = @""; phy.id = @4; _userSubjects = @[math, eng, chem, phy]; } - (NSArray<JLSubject *> *)openSubjectsWithCurrentPhase { return _allSubjects; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLSubjectDataController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
379
```objective-c // // JLSubjectDataController.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLBaseDataController.h" #import "JLSubject.h" @interface JLSubjectDataController : JLBaseDataController @property (nonatomic, strong, nullable) NSArray<JLSubject *> *openSubjectsWithCurrentPhase; - (void)requestAllSubjects; - (void)requestUserSubjects; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLSubjectDataController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
100
```objective-c // // JLBaseDataController.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLBaseDataController.h" @implementation JLBaseDataController - (void)requestWithDataType:(NSString *)type { } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/DataController/JLBaseDataController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
65
```objective-c // // JLSubject.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <Foundation/Foundation.h> @interface JLSubject : NSObject @property (nonatomic, strong, nullable) NSNumber *id; @property (nonatomic, strong, nullable) NSString *name; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/Model/JLSubject.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
71
```objective-c // // JLSubject.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLSubject.h" @implementation JLSubject @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/Model/JLSubject.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
46
```objective-c // // JLHomePracticeViewController.h // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import <UIKit/UIKit.h> @interface JLHomePracticeViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewController/JLHomePracticeViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
51
```objective-c // // YFAnswerViewController.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFAnswerViewController.h" #import "YFAnswerNaviBar.h" #import "YFResizableView.h" @interface YFAnswerViewController ()<YFAnswerNaviBarDelegate,UIScrollViewDelegate> @property (nonatomic, strong) YFAnswerNaviBar *naviBar; @property (nonatomic, strong) YFResizableView *resizableView; @end @implementation YFAnswerViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @""; self.automaticallyAdjustsScrollViewInsets = NO; self.navigationController.navigationBarHidden = YES; self.view.backgroundColor = [UIColor whiteColor]; CGFloat w = YFScreen.width; CGFloat h = YFScreen.height - self.naviBar.frame.size.height; YFResizableView *resizableView = [[YFResizableView alloc] initWithFrame:CGRectMake(0, self.naviBar.frame.size.height, w, h)]; self.resizableView = resizableView; [self.view addSubview:resizableView]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.navigationController.navigationBarHidden = NO; } #pragma mark - setter - (YFAnswerNaviBar *)naviBar { if (!_naviBar) { _naviBar = [[YFAnswerNaviBar alloc] init]; _naviBar.delegate = self; [self.view addSubview:_naviBar]; } return _naviBar; } #pragma mark - YFAnswerNaviBarDelegate - (void)backButtonClick { [self.navigationController popViewControllerAnimated:YES]; } - (CGSize)sizeWithText:(NSString *)text andFont:(UIFont *)font andMaxSize:(CGSize)maxSize { NSDictionary *atts = @{NSFontAttributeName : font}; return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:atts context:nil].size; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
441
```objective-c // // JLHomePracticeViewController.m // MVVM-DataController-Demo // // Created by skyline on 16/3/15. // #import "JLHomePracticeViewController.h" #import "JLHomePracticeActivityView.h" #import "JLHomePracticeBannerView.h" #import "JLHomePracticeSubjectsView.h" #import "JLHomePracticeDataController.h" @interface JLHomePracticeViewController ()<UICollectionViewDelegate> @property (nonatomic, strong, nullable) UIScrollView *contentView; @property (nonatomic, strong, nullable) JLHomePracticeBannerView *bannerView; @property (nonatomic, strong, nullable) JLHomePracticeActivityView *activityView; @property (nonatomic, strong, nullable) JLHomePracticeSubjectsView *subjectsView; @property (nonatomic, strong, nullable) JLHomePracticeDataController *dataController; @end @implementation JLHomePracticeViewController #pragma mark - Life cycle - (void)viewDidLoad { _dataController = [[JLHomePracticeDataController alloc] init]; self.view.backgroundColor = [UIColor lightGrayColor]; [self setupContentView]; [self fetchSubjectData]; } - (void)setupContentView { self.contentView = [[UIScrollView alloc] init]; [self.view addSubview:self.contentView]; self.bannerView = [[JLHomePracticeBannerView alloc] init]; self.activityView = [[JLHomePracticeActivityView alloc] init]; self.subjectsView = [[JLHomePracticeSubjectsView alloc] init]; [self.contentView addSubview:self.bannerView]; [self.contentView addSubview:self.activityView]; [self.contentView addSubview:self.subjectsView]; self.bannerView.frame = CGRectMake(0, 20, 320, 180); self.activityView.frame = CGRectMake(0, 200, 320, 70); self.subjectsView.frame = CGRectMake(0, 270, 200, 200); self.contentView.frame = CGRectMake(0, 0, 320, 568); } #pragma mark - Data - (void)fetchSubjectData { [self.dataController requestSubjectDataWithCallback:^(NSError *error) { if (error == nil) { [self renderSubjectView]; } }]; } - (void)renderSubjectView { JLHomePracticeSubjectsViewModel *viewModel = [JLHomePracticeSubjectsViewModel viewModelWithSubjects:self.dataController.openSubjects]; [self.subjectsView bindDataWithViewModel:viewModel]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/SystemArchitecture/ViewController/JLHomePracticeViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
514
```objective-c // // YFAnswerNaviBar.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> @protocol YFAnswerNaviBarDelegate <NSObject> @required - (void)backButtonClick; @end @interface YFAnswerNaviBar : UIView @property (nonatomic, assign) id<YFAnswerNaviBarDelegate> delegate; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerNaviBar.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
93
```objective-c // // YFResizableView.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> #import "YFQuestionBox.h" #import "YFAnswerBox.h" #import "YFDragButton.h" @interface YFResizableView : UIScrollView @property (nonatomic, strong) YFQuestionBox *questionBox; @property (nonatomic, strong) YFAnswerBox *answerBox; @property (nonatomic, strong) YFDragButton *dragButton; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFResizableView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
116
```objective-c // // YFAnswerBox.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> @interface YFAnswerBox : UIScrollView @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerBox.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
48
```objective-c // // YFQuestionBox.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFQuestionBox.h" #define padding 10 @implementation YFQuestionBox - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFrame:) name:@"changeFrame" object:nil]; [self makeView:frame]; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeFrame" object:nil]; } - (void)makeView:(CGRect)frame { self.frame = frame; UILabel *label = [[UILabel alloc] init]; label.font = [UIFont systemFontOfSize:17]; label.text = @" \n \n \n ____________"; label.numberOfLines = 0; CGSize labelMaxSize = CGSizeMake(frame.size.width - 2 * padding, MAXFLOAT); CGSize labelSize = [self sizeWithText:label.text andFont:label.font andMaxSize:labelMaxSize]; label.frame = CGRectMake(padding, padding, labelMaxSize.width, labelSize.height); self.contentSize = CGSizeMake(0, labelSize.height); self.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); self.bounces = NO; [self addSubview:label]; } - (CGSize)sizeWithText:(NSString *)text andFont:(UIFont *)font andMaxSize:(CGSize)maxSize { NSDictionary *atts = @{NSFontAttributeName : font}; return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:atts context:nil].size; } - (void)changeFrame:(NSNotification *)noti { CGFloat y = [noti.object floatValue]; CGRect tempF = self.frame; tempF = CGRectMake(tempF.origin.x, tempF.origin.y, tempF.size.width, tempF.size.height + y); self.frame = tempF; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFQuestionBox.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
438
```objective-c // // YFDragButton.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> @interface YFDragButton : UIButton @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFDragButton.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
48
```objective-c // // YFQuestionBox.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> @interface YFQuestionBox : UIScrollView @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFQuestionBox.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
48
```objective-c // // YFAnswerBox.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFAnswerBox.h" @implementation YFAnswerBox - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFrame:) name:@"changeFrame" object:nil]; [self makeView:frame]; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeFrame" object:nil]; } - (void)makeView:(CGRect)frame { self.frame = frame; self.contentSize = CGSizeMake(0, 800); self.backgroundColor = [UIColor whiteColor]; // UIButton *dragBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 30)]; // dragBtn.center = CGPointMake(frame.size.width * 0.5, 10); // [dragBtn setImage:[UIImage imageNamed:@"dragBtn"] forState:UIControlStateNormal]; // [self addSubview:dragBtn]; } #pragma mark - YFDragButtonDelegate - (void)changeSelfFrame:(CGFloat)y { CGRect tempF = self.frame; tempF = CGRectMake(tempF.origin.x, tempF.origin.y + y, tempF.size.width, tempF.size.height - y); self.frame = tempF; } - (void)changeFrame:(NSNotification *)noti { CGFloat y = [noti.object floatValue]; CGRect tempF = self.frame; tempF = CGRectMake(tempF.origin.x, tempF.origin.y + y, tempF.size.width, tempF.size.height - y); self.frame = tempF; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerBox.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
368
```objective-c // // YFDragButton.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFDragButton.h" @implementation YFDragButton - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFrame:) name:@"changeFrame" object:nil]; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeFrame" object:nil]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; NSLog(@"self.frame.origin.y = %f", self.frame.origin.y); if (self.frame.origin.y < 80 && point.y < 0) { // // BUG: , return; } if (self.frame.origin.y > self.superview.frame.size.height - self.frame.size.height - 20 && point.y > 0) { // return; } NSString *str = [NSString stringWithFormat:@"%f", point.y]; [[NSNotificationCenter defaultCenter] postNotificationName:@"changeFrame" object:str]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesBegan---------button"); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesEnded---------button"); } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesEnded---------button"); } - (void)changeFrame:(NSNotification *)noti { CGFloat y = [noti.object floatValue]; CGRect btnF = self.frame; CGFloat newY = btnF.origin.y + y; // if (newY < 80) { // // newY = 80; // } // // if (newY > self.superview.frame.size.height - self.frame.size.height - 20) { // // newY = self.superview.frame.size.height - self.frame.size.height - 20; // } btnF = CGRectMake(btnF.origin.x, newY, btnF.size.width, btnF.size.height); self.frame = btnF; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFDragButton.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
515
```objective-c // // YFAnswerNaviBar.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFAnswerNaviBar.h" @implementation YFAnswerNaviBar - (instancetype)init { self = [super init]; if (self) { self.frame = CGRectMake(0, 0, YFScreen.width, 64); self.backgroundColor = [UIColor darkGrayColor]; [self makeView]; } return self; } - (void)makeView { UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 64)]; // btn.backgroundColor = [UIColor redColor]; [btn setTitle:@"back" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:btn]; } - (void)backButtonClick { [self.delegate backButtonClick]; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerNaviBar.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
204
```objective-c // // YFAnswerViewController.h // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import <UIKit/UIKit.h> @interface YFAnswerViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFAnswerViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
48
```objective-c // // YFWeChatViewController.h // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "BaseTableViewController.h" @interface YFWeChatViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/YFWeChatViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
55
```objective-c // // YFWeChatViewController.m // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "YFWeChatViewController.h" @interface YFWeChatViewController () @end @implementation YFWeChatViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"",@"YFWeChatShakeViewController"], @[@"",@"YFAnimationCircleButtonVC"],]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/YFWeChatViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
190
```objective-c // // YFResizableView.m // AnswerQuestions // // Created by zhht01 on 16/3/29. // #import "YFResizableView.h" #define questCount 5 @implementation YFResizableView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor lightGrayColor]; self.contentSize = CGSizeMake(5 * frame.size.width, 0); self.showsHorizontalScrollIndicator = NO; self.pagingEnabled = YES; [self makeView:frame]; } return self; } - (void)makeView:(CGRect)frame { CGFloat w = frame.size.width; CGFloat h = frame.size.height; for (int i = 0; i< questCount; i++) { // questionBox YFQuestionBox *questionBox = [[YFQuestionBox alloc] initWithFrame:CGRectMake(i * w, 0, w, h * 0.5)]; [self addSubview:questionBox]; self.questionBox = questionBox; // answerBox YFAnswerBox *answerBox = [[YFAnswerBox alloc] initWithFrame:CGRectMake(i * w, h * 0.5, w, h * 0.5)]; [self addSubview:answerBox]; self.answerBox = answerBox; // dragButton CGFloat dragW = 70; CGFloat dragH = 20; CGFloat dragX = (w - dragW) * 0.5 + i * w; CGFloat dragY = CGRectGetMinY(answerBox.frame) - dragH; YFDragButton *dragButton = [[YFDragButton alloc] initWithFrame:CGRectMake(dragX, dragY, dragW, dragH)]; [dragButton setBackgroundImage:[UIImage imageNamed:@"dragBtn"] forState:UIControlStateNormal]; [dragButton setBackgroundImage:[UIImage imageNamed:@"dragBtn"] forState:UIControlStateHighlighted]; [self addSubview:dragButton]; self.dragButton = dragButton; } } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/猿题库/AnswerQuestions/YFResizableView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
436
```objective-c // // HMAudioTool.m // // // Created by apple on 14-8-8. // #import "LZAudioTool.h" #import <AVFoundation/AVFoundation.h> @implementation LZAudioTool /** * */ static NSMutableDictionary *_musicPlayers; + (NSMutableDictionary *)musicPlayers { if (!_musicPlayers) { _musicPlayers = [NSMutableDictionary dictionary]; } return _musicPlayers; } /** * * * @param filename */ + (BOOL)playMusic:(NSString *)filename { if (!filename) return NO; AVAudioPlayer *player = [self musicPlayers][filename]; if (!player) { NSURL *url = [[NSBundle mainBundle] URLForResource:filename withExtension:nil]; if (!url) return NO; player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; if (![player prepareToPlay]) return NO; [self musicPlayers][filename] = player; } if (!player.isPlaying) { return [player play]; } return YES; } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/摇一摇/LZAudioTool.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
236
```objective-c // // HMAudioTool.h // // // Created by apple on 14-8-8. // #import <Foundation/Foundation.h> @interface LZAudioTool : NSObject /** * * * @param filename */ + (BOOL)playMusic:(NSString *)filename; @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/摇一摇/LZAudioTool.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
64
```objective-c // // YFWeChatShakeViewController.h // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "BaseTableViewController.h" @interface YFWeChatShakeViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/摇一摇/YFWeChatShakeViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
59
```objective-c // // YFWeChatShakeViewController.m // BigShow1949 // // Created by zhht01 on 16/1/22. // #import "YFWeChatShakeViewController.h" #import "LZAudioTool.h" @interface YFWeChatShakeViewController () @property (nonatomic, weak) UIImageView *bg; @property (nonatomic, weak) UIImageView *up; @property (nonatomic, weak) UIImageView *down; @end @implementation YFWeChatShakeViewController - (void)viewDidLoad { [super viewDidLoad]; UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIImage imageNamed:@"bg_shaking"]; bg.frame = self.view.bounds; [self.view addSubview:bg]; self.bg = bg; UIImageView *up = [[UIImageView alloc] init]; up.image = [UIImage imageNamed:@"bg_yaoyao_above"]; up.frame = CGRectMake(0, 0, self.view.width, self.view.height * 0.5); [bg addSubview:up]; self.up = up; UIImageView *down = [[UIImageView alloc] init]; down.image = [UIImage imageNamed:@"bg_yaoyao_under"]; down.frame = CGRectMake(0, self.view.height * 0.5, self.view.width, self.view.height * 0.5); [bg addSubview:down]; self.down = down; } -(BOOL)canBecomeFirstResponder { return YES; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self becomeFirstResponder]; } -(void)viewWillDisappear:(BOOL)animated { [self resignFirstResponder]; [super viewWillDisappear:animated]; } #pragma mark - /** */ - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"motionBegan"); CGFloat offset = self.bg.height/2; CGFloat duration = 0.4; [UIView animateWithDuration:duration animations:^{ self.up.y -= offset; self.down.y += offset; }]; [LZAudioTool playMusic:@"dance.mp3"]; } /** */ - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { // if (motion != UIEventSubtypeMotionShake) return; NSLog(@"motionEnded"); CGFloat offset = self.bg.height / 2; CGFloat duration = 0.4; [UIView animateWithDuration:duration animations:^{ self.up.y += offset; self.down.y -= offset; }]; } /** */ - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"motionCancelled"); } @end ```
/content/code_sandbox/BigShow1949/Classes/09 - ImitateApp(仿主流app)/微信/摇一摇/YFWeChatShakeViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
585
```objective-c // // AppDelegate.h // BigShow1949 // // Created by WangMengqi on 15/9/1. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Other/AppDelegate.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
57
```objective-c // // main.m // BigShow1949 // // Created by WangMengqi on 15/9/1. // #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ```
/content/code_sandbox/BigShow1949/Classes/Main/Other/main.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
75
```objective-c // // AppDelegate.m // BigShow1949 // // Created by WangMengqi on 15/9/1. // #import "AppDelegate.h" #import "YFHomeViewController.h" #import "JLRoutes.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; YFHomeViewController *vc = [[YFHomeViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; self.window.rootViewController = nav; [self.window makeKeyAndVisible]; return YES; } - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskPortrait; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { NSLog(@"url = %@", url); return [[JLRoutes globalRoutes]routeURL:url];; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Other/AppDelegate.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
530
```objective-c // : path_to_url // : path_to_url #import <UIKit/UIKit.h> #import <objc/message.h> // #define MJWeakSelf __weak typeof(self) weakSelf = self; // #ifdef DEBUG #define MJRefreshLog(...) NSLog(__VA_ARGS__) #else #define MJRefreshLog(...) #endif // #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) // objc_msgSend #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) #define MJRefreshMsgTarget(target) (__bridge void *)(target) // RGB #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] // #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) // #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] // UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset; UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText; UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText; UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText; // #define MJRefreshCheckState \ MJRefreshState oldState = self.state; \ if (state == oldState) return; \ [super setState:state]; ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/MJRefreshConst.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
542
```objective-c // : path_to_url // : path_to_url #import <UIKit/UIKit.h> const CGFloat MJRefreshLabelLeftInset = 25; const CGFloat MJRefreshHeaderHeight = 54.0; const CGFloat MJRefreshFooterHeight = 44.0; const CGFloat MJRefreshFastAnimationDuration = 0.25; const CGFloat MJRefreshSlowAnimationDuration = 0.4; NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; NSString *const MJRefreshKeyPathContentInset = @"contentInset"; NSString *const MJRefreshKeyPathContentSize = @"contentSize"; NSString *const MJRefreshKeyPathPanState = @"state"; NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; NSString *const MJRefreshHeaderIdleText = @"MJRefreshHeaderIdleText"; NSString *const MJRefreshHeaderPullingText = @"MJRefreshHeaderPullingText"; NSString *const MJRefreshHeaderRefreshingText = @"MJRefreshHeaderRefreshingText"; NSString *const MJRefreshAutoFooterIdleText = @"MJRefreshAutoFooterIdleText"; NSString *const MJRefreshAutoFooterRefreshingText = @"MJRefreshAutoFooterRefreshingText"; NSString *const MJRefreshAutoFooterNoMoreDataText = @"MJRefreshAutoFooterNoMoreDataText"; NSString *const MJRefreshBackFooterIdleText = @"MJRefreshBackFooterIdleText"; NSString *const MJRefreshBackFooterPullingText = @"MJRefreshBackFooterPullingText"; NSString *const MJRefreshBackFooterRefreshingText = @"MJRefreshBackFooterRefreshingText"; NSString *const MJRefreshBackFooterNoMoreDataText = @"MJRefreshBackFooterNoMoreDataText"; NSString *const MJRefreshHeaderLastTimeText = @"MJRefreshHeaderLastTimeText"; NSString *const MJRefreshHeaderDateTodayText = @"MJRefreshHeaderDateTodayText"; NSString *const MJRefreshHeaderNoneLastDateText = @"MJRefreshHeaderNoneLastDateText"; ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/MJRefreshConst.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
398
```objective-c // : path_to_url // : path_to_url // UIView+Extension.m // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import "UIView+MJExtension.h" @implementation UIView (MJExtension) - (void)setMj_x:(CGFloat)mj_x { CGRect frame = self.frame; frame.origin.x = mj_x; self.frame = frame; } - (CGFloat)mj_x { return self.frame.origin.x; } - (void)setMj_y:(CGFloat)mj_y { CGRect frame = self.frame; frame.origin.y = mj_y; self.frame = frame; } - (CGFloat)mj_y { return self.frame.origin.y; } - (void)setMj_w:(CGFloat)mj_w { CGRect frame = self.frame; frame.size.width = mj_w; self.frame = frame; } - (CGFloat)mj_w { return self.frame.size.width; } - (void)setMj_h:(CGFloat)mj_h { CGRect frame = self.frame; frame.size.height = mj_h; self.frame = frame; } - (CGFloat)mj_h { return self.frame.size.height; } - (void)setMj_size:(CGSize)mj_size { CGRect frame = self.frame; frame.size = mj_size; self.frame = frame; } - (CGSize)mj_size { return self.frame.size; } - (void)setMj_origin:(CGPoint)mj_origin { CGRect frame = self.frame; frame.origin = mj_origin; self.frame = frame; } - (CGPoint)mj_origin { return self.frame.origin; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIView+MJExtension.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
368
```objective-c // // NSBundle+MJRefresh.h // MJRefreshExample // // Created by MJ Lee on 16/6/13. // #import <UIKit/UIKit.h> @interface NSBundle (MJRefresh) + (instancetype)mj_refreshBundle; + (UIImage *)mj_arrowImage; + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value; + (NSString *)mj_localizedStringForKey:(NSString *)key; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/NSBundle+MJRefresh.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
97
```objective-c // : path_to_url // : path_to_url // UIView+Extension.h // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import <UIKit/UIKit.h> @interface UIView (MJExtension) @property (assign, nonatomic) CGFloat mj_x; @property (assign, nonatomic) CGFloat mj_y; @property (assign, nonatomic) CGFloat mj_w; @property (assign, nonatomic) CGFloat mj_h; @property (assign, nonatomic) CGSize mj_size; @property (assign, nonatomic) CGPoint mj_origin; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIView+MJExtension.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
116
```objective-c // : path_to_url // : path_to_url // UIScrollView+Extension.h // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import <UIKit/UIKit.h> @interface UIScrollView (MJExtension) @property (assign, nonatomic) CGFloat mj_insetT; @property (assign, nonatomic) CGFloat mj_insetB; @property (assign, nonatomic) CGFloat mj_insetL; @property (assign, nonatomic) CGFloat mj_insetR; @property (assign, nonatomic) CGFloat mj_offsetX; @property (assign, nonatomic) CGFloat mj_offsetY; @property (assign, nonatomic) CGFloat mj_contentW; @property (assign, nonatomic) CGFloat mj_contentH; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIScrollView+MJExtension.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
150
```objective-c // : path_to_url // : path_to_url // UIScrollView+MJRefresh.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // ScrollView #import <UIKit/UIKit.h> #import "MJRefreshConst.h" @class MJRefreshHeader, MJRefreshFooter; @interface UIScrollView (MJRefresh) /** */ @property (strong, nonatomic) MJRefreshHeader *mj_header; @property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("mj_header"); /** */ @property (strong, nonatomic) MJRefreshFooter *mj_footer; @property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("mj_footer"); #pragma mark - other - (NSInteger)mj_totalDataCount; @property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIScrollView+MJRefresh.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
178
```objective-c // // NSBundle+MJRefresh.m // MJRefreshExample // // Created by MJ Lee on 16/6/13. // #import "NSBundle+MJRefresh.h" #import "MJRefreshComponent.h" @implementation NSBundle (MJRefresh) + (instancetype)mj_refreshBundle { static NSBundle *refreshBundle = nil; if (refreshBundle == nil) { // mainBundlepod 1.x0.x refreshBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[MJRefreshComponent class]] pathForResource:@"MJRefresh" ofType:@"bundle"]]; } return refreshBundle; } + (UIImage *)mj_arrowImage { static UIImage *arrowImage = nil; if (arrowImage == nil) { arrowImage = [[UIImage imageWithContentsOfFile:[[self mj_refreshBundle] pathForResource:@"arrow@2x" ofType:@"png"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } return arrowImage; } + (NSString *)mj_localizedStringForKey:(NSString *)key { return [self mj_localizedStringForKey:key value:nil]; } + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value { static NSBundle *bundle = nil; if (bundle == nil) { // iOSenzh-Hanszh-Hant NSString *language = [NSLocale preferredLanguages].firstObject; if ([language hasPrefix:@"en"]) { language = @"en"; } else if ([language hasPrefix:@"zh"]) { if ([language rangeOfString:@"Hans"].location != NSNotFound) { language = @"zh-Hans"; // } else { // zh-Hant\zh-HK\zh-TW language = @"zh-Hant"; // } } else { language = @"en"; } // MJRefresh.bundle bundle = [NSBundle bundleWithPath:[[NSBundle mj_refreshBundle] pathForResource:language ofType:@"lproj"]]; } value = [bundle localizedStringForKey:key value:value table:nil]; return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/NSBundle+MJRefresh.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
453
```objective-c // : path_to_url // : path_to_url // UIScrollView+Extension.m // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import "UIScrollView+MJExtension.h" #import <objc/runtime.h> @implementation UIScrollView (MJExtension) - (void)setMj_insetT:(CGFloat)mj_insetT { UIEdgeInsets inset = self.contentInset; inset.top = mj_insetT; self.contentInset = inset; } - (CGFloat)mj_insetT { return self.contentInset.top; } - (void)setMj_insetB:(CGFloat)mj_insetB { UIEdgeInsets inset = self.contentInset; inset.bottom = mj_insetB; self.contentInset = inset; } - (CGFloat)mj_insetB { return self.contentInset.bottom; } - (void)setMj_insetL:(CGFloat)mj_insetL { UIEdgeInsets inset = self.contentInset; inset.left = mj_insetL; self.contentInset = inset; } - (CGFloat)mj_insetL { return self.contentInset.left; } - (void)setMj_insetR:(CGFloat)mj_insetR { UIEdgeInsets inset = self.contentInset; inset.right = mj_insetR; self.contentInset = inset; } - (CGFloat)mj_insetR { return self.contentInset.right; } - (void)setMj_offsetX:(CGFloat)mj_offsetX { CGPoint offset = self.contentOffset; offset.x = mj_offsetX; self.contentOffset = offset; } - (CGFloat)mj_offsetX { return self.contentOffset.x; } - (void)setMj_offsetY:(CGFloat)mj_offsetY { CGPoint offset = self.contentOffset; offset.y = mj_offsetY; self.contentOffset = offset; } - (CGFloat)mj_offsetY { return self.contentOffset.y; } - (void)setMj_contentW:(CGFloat)mj_contentW { CGSize size = self.contentSize; size.width = mj_contentW; self.contentSize = size; } - (CGFloat)mj_contentW { return self.contentSize.width; } - (void)setMj_contentH:(CGFloat)mj_contentH { CGSize size = self.contentSize; size.height = mj_contentH; self.contentSize = size; } - (CGFloat)mj_contentH { return self.contentSize.height; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIScrollView+MJExtension.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
526
```objective-c // : path_to_url // : path_to_url #import "UIScrollView+MJRefresh.h" #import "UIScrollView+MJExtension.h" #import "UIView+MJExtension.h" #import "MJRefreshNormalHeader.h" #import "MJRefreshGifHeader.h" #import "MJRefreshBackNormalFooter.h" #import "MJRefreshBackGifFooter.h" #import "MJRefreshAutoNormalFooter.h" #import "MJRefreshAutoGifFooter.h" ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/MJRefresh.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
94
```objective-c // : path_to_url // : path_to_url // MJRefreshFooter.h // MJRefreshExample // // Created by MJ Lee on 15/3/5. // #import "MJRefreshComponent.h" @interface MJRefreshFooter : MJRefreshComponent /** footer */ + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; /** footer */ + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** */ - (void)endRefreshingWithNoMoreData; - (void)noticeNoMoreData MJRefreshDeprecated("endRefreshingWithNoMoreData"); /** */ - (void)resetNoMoreData; /** scrollViewcontentInsetbottom */ @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; /** NO */ @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
190
```objective-c // // MJRefreshBackFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshFooter.h" @interface MJRefreshBackFooter : MJRefreshFooter @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshBackFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
51
```objective-c // : path_to_url // : path_to_url // UIScrollView+MJRefresh.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "UIScrollView+MJRefresh.h" #import "MJRefreshHeader.h" #import "MJRefreshFooter.h" #import <objc/runtime.h> @implementation NSObject (MJRefresh) + (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2 { method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2)); } + (void)exchangeClassMethod1:(SEL)method1 method2:(SEL)method2 { method_exchangeImplementations(class_getClassMethod(self, method1), class_getClassMethod(self, method2)); } @end @implementation UIScrollView (MJRefresh) #pragma mark - header static const char MJRefreshHeaderKey = '\0'; - (void)setMj_header:(MJRefreshHeader *)mj_header { if (mj_header != self.mj_header) { // [self.mj_header removeFromSuperview]; [self insertSubview:mj_header atIndex:0]; // [self willChangeValueForKey:@"mj_header"]; // KVO objc_setAssociatedObject(self, &MJRefreshHeaderKey, mj_header, OBJC_ASSOCIATION_ASSIGN); [self didChangeValueForKey:@"mj_header"]; // KVO } } - (MJRefreshHeader *)mj_header { return objc_getAssociatedObject(self, &MJRefreshHeaderKey); } #pragma mark - footer static const char MJRefreshFooterKey = '\0'; - (void)setMj_footer:(MJRefreshFooter *)mj_footer { if (mj_footer != self.mj_footer) { // [self.mj_footer removeFromSuperview]; [self insertSubview:mj_footer atIndex:0]; // [self willChangeValueForKey:@"mj_footer"]; // KVO objc_setAssociatedObject(self, &MJRefreshFooterKey, mj_footer, OBJC_ASSOCIATION_ASSIGN); [self didChangeValueForKey:@"mj_footer"]; // KVO } } - (MJRefreshFooter *)mj_footer { return objc_getAssociatedObject(self, &MJRefreshFooterKey); } #pragma mark - - (void)setFooter:(MJRefreshFooter *)footer { self.mj_footer = footer; } - (MJRefreshFooter *)footer { return self.mj_footer; } - (void)setHeader:(MJRefreshHeader *)header { self.mj_header = header; } - (MJRefreshHeader *)header { return self.mj_header; } #pragma mark - other - (NSInteger)mj_totalDataCount { NSInteger totalCount = 0; if ([self isKindOfClass:[UITableView class]]) { UITableView *tableView = (UITableView *)self; for (NSInteger section = 0; section<tableView.numberOfSections; section++) { totalCount += [tableView numberOfRowsInSection:section]; } } else if ([self isKindOfClass:[UICollectionView class]]) { UICollectionView *collectionView = (UICollectionView *)self; for (NSInteger section = 0; section<collectionView.numberOfSections; section++) { totalCount += [collectionView numberOfItemsInSection:section]; } } return totalCount; } static const char MJRefreshReloadDataBlockKey = '\0'; - (void)setMj_reloadDataBlock:(void (^)(NSInteger))mj_reloadDataBlock { [self willChangeValueForKey:@"mj_reloadDataBlock"]; // KVO objc_setAssociatedObject(self, &MJRefreshReloadDataBlockKey, mj_reloadDataBlock, OBJC_ASSOCIATION_COPY_NONATOMIC); [self didChangeValueForKey:@"mj_reloadDataBlock"]; // KVO } - (void (^)(NSInteger))mj_reloadDataBlock { return objc_getAssociatedObject(self, &MJRefreshReloadDataBlockKey); } - (void)executeReloadDataBlock { !self.mj_reloadDataBlock ? : self.mj_reloadDataBlock(self.mj_totalDataCount); } @end @implementation UITableView (MJRefresh) + (void)load { [self exchangeInstanceMethod1:@selector(reloadData) method2:@selector(mj_reloadData)]; } - (void)mj_reloadData { [self mj_reloadData]; [self executeReloadDataBlock]; } @end @implementation UICollectionView (MJRefresh) + (void)load { [self exchangeInstanceMethod1:@selector(reloadData) method2:@selector(mj_reloadData)]; } - (void)mj_reloadData { [self mj_reloadData]; [self executeReloadDataBlock]; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/UIScrollView+MJRefresh.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
980
```objective-c // : path_to_url // : path_to_url // MJRefreshHeader.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // : #import "MJRefreshComponent.h" @interface MJRefreshHeader : MJRefreshComponent /** header */ + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; /** header */ + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** key */ @property (copy, nonatomic) NSString *lastUpdatedTimeKey; /** */ @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; /** scrollViewcontentInsettop */ @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshHeader.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
160
```objective-c // // MJRefreshAutoFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoFooter.h" @interface MJRefreshAutoFooter() @end @implementation MJRefreshAutoFooter #pragma mark - - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; if (newSuperview) { // if (self.hidden == NO) { self.scrollView.mj_insetB += self.mj_h; } // self.mj_y = _scrollView.mj_contentH; } else { // if (self.hidden == NO) { self.scrollView.mj_insetB -= self.mj_h; } } } #pragma mark - - (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh { self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; } - (CGFloat)appearencePercentTriggerAutoRefresh { return self.triggerAutomaticallyRefreshPercent; } #pragma mark - - (void)prepare { [super prepare]; // 100% self.triggerAutomaticallyRefreshPercent = 1.0; // self.automaticallyRefresh = YES; } - (void)scrollViewContentSizeDidChange:(NSDictionary *)change { [super scrollViewContentSizeDidChange:change]; // self.mj_y = self.scrollView.mj_contentH; } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // // _scrollView.mj_contentHself.mj_y if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { // CGPoint old = [change[@"old"] CGPointValue]; CGPoint new = [change[@"new"] CGPointValue]; if (new.y <= old.y) return; // [self beginRefreshing]; } } } - (void)scrollViewPanStateDidChange:(NSDictionary *)change { [super scrollViewPanStateDidChange:change]; if (self.state != MJRefreshStateIdle) return; if (_scrollView.panGestureRecognizer.state == UIGestureRecognizerStateEnded) {// if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // [self beginRefreshing]; } } else { // if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { [self beginRefreshing]; } } } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState if (state == MJRefreshStateRefreshing) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self executeRefreshingCallback]; }); } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { if (MJRefreshStateRefreshing == oldState) { if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } } } } - (void)setHidden:(BOOL)hidden { BOOL lastHidden = self.isHidden; [super setHidden:hidden]; if (!lastHidden && hidden) { self.state = MJRefreshStateIdle; self.scrollView.mj_insetB -= self.mj_h; } else if (lastHidden && !hidden) { self.scrollView.mj_insetB += self.mj_h; // self.mj_y = _scrollView.mj_contentH; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshAutoFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
874
```objective-c // : path_to_url // : path_to_url // MJRefreshHeader.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "MJRefreshHeader.h" @interface MJRefreshHeader() @property (assign, nonatomic) CGFloat insetTDelta; @end @implementation MJRefreshHeader #pragma mark - + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock { MJRefreshHeader *cmp = [[self alloc] init]; cmp.refreshingBlock = refreshingBlock; return cmp; } + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action { MJRefreshHeader *cmp = [[self alloc] init]; [cmp setRefreshingTarget:target refreshingAction:action]; return cmp; } #pragma mark - - (void)prepare { [super prepare]; // key self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey; // self.mj_h = MJRefreshHeaderHeight; } - (void)placeSubviews { [super placeSubviews]; // y(YplaceSubviewsy) self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop; } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; // refreshing if (self.state == MJRefreshStateRefreshing) { if (self.window == nil) return; // sectionheader CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top; insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT; self.scrollView.mj_insetT = insetT; self.insetTDelta = _scrollViewOriginalInset.top - insetT; return; } // contentInset _scrollViewOriginalInset = self.scrollView.contentInset; // contentOffset CGFloat offsetY = self.scrollView.mj_offsetY; // offsetY CGFloat happenOffsetY = - self.scrollViewOriginalInset.top; // // >= -> > if (offsetY > happenOffsetY) return; // CGFloat normal2pullingOffsetY = happenOffsetY - self.mj_h; CGFloat pullingPercent = (happenOffsetY - offsetY) / self.mj_h; if (self.scrollView.isDragging) { // self.pullingPercent = pullingPercent; if (self.state == MJRefreshStateIdle && offsetY < normal2pullingOffsetY) { // self.state = MJRefreshStatePulling; } else if (self.state == MJRefreshStatePulling && offsetY >= normal2pullingOffsetY) { // self.state = MJRefreshStateIdle; } } else if (self.state == MJRefreshStatePulling) {// && // [self beginRefreshing]; } else if (pullingPercent < 1) { self.pullingPercent = pullingPercent; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState != MJRefreshStateRefreshing) return; // [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.lastUpdatedTimeKey]; [[NSUserDefaults standardUserDefaults] synchronize]; // insetoffset [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.scrollView.mj_insetT += self.insetTDelta; // if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; } completion:^(BOOL finished) { self.pullingPercent = 0.0; if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } }]; } else if (state == MJRefreshStateRefreshing) { dispatch_async(dispatch_get_main_queue(), ^{ [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; // top self.scrollView.mj_insetT = top; // [self.scrollView setContentOffset:CGPointMake(0, -top) animated:NO]; } completion:^(BOOL finished) { [self executeRefreshingCallback]; }]; }); } } #pragma mark - - (void)endRefreshing { dispatch_async(dispatch_get_main_queue(), ^{ self.state = MJRefreshStateIdle; }); } - (NSDate *)lastUpdatedTime { return [[NSUserDefaults standardUserDefaults] objectForKey:self.lastUpdatedTimeKey]; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshHeader.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,005
```objective-c // : path_to_url // : path_to_url // MJRefreshComponent.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "MJRefreshComponent.h" #import "MJRefreshConst.h" @interface MJRefreshComponent() @property (strong, nonatomic) UIPanGestureRecognizer *pan; @end @implementation MJRefreshComponent #pragma mark - - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // [self prepare]; // self.state = MJRefreshStateIdle; } return self; } - (void)prepare { // self.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.backgroundColor = [UIColor clearColor]; } - (void)layoutSubviews { [self placeSubviews]; [super layoutSubviews]; } - (void)placeSubviews{} - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; // UIScrollView if (newSuperview && ![newSuperview isKindOfClass:[UIScrollView class]]) return; // [self removeObservers]; if (newSuperview) { // // self.mj_w = newSuperview.mj_w; // self.mj_x = 0; // UIScrollView _scrollView = (UIScrollView *)newSuperview; // _scrollView.alwaysBounceVertical = YES; // UIScrollViewcontentInset _scrollViewOriginalInset = _scrollView.contentInset; // [self addObservers]; } } - (void)drawRect:(CGRect)rect { [super drawRect:rect]; if (self.state == MJRefreshStateWillRefresh) { // viewbeginRefreshing self.state = MJRefreshStateRefreshing; } } #pragma mark - KVO - (void)addObservers { NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld; [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentOffset options:options context:nil]; [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentSize options:options context:nil]; self.pan = self.scrollView.panGestureRecognizer; [self.pan addObserver:self forKeyPath:MJRefreshKeyPathPanState options:options context:nil]; } - (void)removeObservers { [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentOffset]; [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentSize];; [self.pan removeObserver:self forKeyPath:MJRefreshKeyPathPanState]; self.pan = nil; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { // if (!self.userInteractionEnabled) return; // if ([keyPath isEqualToString:MJRefreshKeyPathContentSize]) { [self scrollViewContentSizeDidChange:change]; } // if (self.hidden) return; if ([keyPath isEqualToString:MJRefreshKeyPathContentOffset]) { [self scrollViewContentOffsetDidChange:change]; } else if ([keyPath isEqualToString:MJRefreshKeyPathPanState]) { [self scrollViewPanStateDidChange:change]; } } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change{} - (void)scrollViewContentSizeDidChange:(NSDictionary *)change{} - (void)scrollViewPanStateDidChange:(NSDictionary *)change{} #pragma mark - #pragma mark - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action { self.refreshingTarget = target; self.refreshingAction = action; } - (void)setState:(MJRefreshState)state { _state = state; // setState: dispatch_async(dispatch_get_main_queue(), ^{ [self setNeedsLayout]; }); } #pragma mark - (void)beginRefreshing { [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.alpha = 1.0; }]; self.pullingPercent = 1.0; // if (self.window) { self.state = MJRefreshStateRefreshing; } else { // header inset if (self.state != MJRefreshStateRefreshing) { self.state = MJRefreshStateWillRefresh; // () [self setNeedsDisplay]; } } } - (void)beginRefreshingWithCompletionBlock:(void (^)())completionBlock { self.beginRefreshingCompletionBlock = completionBlock; [self beginRefreshing]; } #pragma mark - (void)endRefreshing { self.state = MJRefreshStateIdle; } - (void)endRefreshingWithCompletionBlock:(void (^)())completionBlock { self.endRefreshingCompletionBlock = completionBlock; [self endRefreshing]; } #pragma mark - (BOOL)isRefreshing { return self.state == MJRefreshStateRefreshing || self.state == MJRefreshStateWillRefresh; } #pragma mark - (void)setAutoChangeAlpha:(BOOL)autoChangeAlpha { self.automaticallyChangeAlpha = autoChangeAlpha; } - (BOOL)isAutoChangeAlpha { return self.isAutomaticallyChangeAlpha; } - (void)setAutomaticallyChangeAlpha:(BOOL)automaticallyChangeAlpha { _automaticallyChangeAlpha = automaticallyChangeAlpha; if (self.isRefreshing) return; if (automaticallyChangeAlpha) { self.alpha = self.pullingPercent; } else { self.alpha = 1.0; } } #pragma mark - (void)setPullingPercent:(CGFloat)pullingPercent { _pullingPercent = pullingPercent; if (self.isRefreshing) return; if (self.isAutomaticallyChangeAlpha) { self.alpha = pullingPercent; } } #pragma mark - - (void)executeRefreshingCallback { dispatch_async(dispatch_get_main_queue(), ^{ if (self.refreshingBlock) { self.refreshingBlock(); } if ([self.refreshingTarget respondsToSelector:self.refreshingAction]) { MJRefreshMsgSend(MJRefreshMsgTarget(self.refreshingTarget), self.refreshingAction, self); } if (self.beginRefreshingCompletionBlock) { self.beginRefreshingCompletionBlock(); } }); } @end @implementation UILabel(MJRefresh) + (instancetype)mj_label { UILabel *label = [[self alloc] init]; label.font = MJRefreshLabelFont; label.textColor = MJRefreshLabelTextColor; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.textAlignment = NSTextAlignmentCenter; label.backgroundColor = [UIColor clearColor]; return label; } - (CGFloat)mj_textWith { CGFloat stringWidth = 0; CGSize size = CGSizeMake(MAXFLOAT, MAXFLOAT); if (self.text.length > 0) { #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 stringWidth =[self.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size.width; #else stringWidth = [self.text sizeWithFont:self.font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping].width; #endif } return stringWidth; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshComponent.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,569
```objective-c // : path_to_url // : path_to_url // MJRefreshComponent.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import <UIKit/UIKit.h> #import "MJRefreshConst.h" #import "UIView+MJExtension.h" #import "UIScrollView+MJExtension.h" #import "UIScrollView+MJRefresh.h" #import "NSBundle+MJRefresh.h" /** */ typedef NS_ENUM(NSInteger, MJRefreshState) { /** */ MJRefreshStateIdle = 1, /** */ MJRefreshStatePulling, /** */ MJRefreshStateRefreshing, /** */ MJRefreshStateWillRefresh, /** */ MJRefreshStateNoMoreData }; /** */ typedef void (^MJRefreshComponentRefreshingBlock)(); /** () */ typedef void (^MJRefreshComponentbeginRefreshingCompletionBlock)(); /** */ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(); /** */ @interface MJRefreshComponent : UIView { /** scrollViewinset */ UIEdgeInsets _scrollViewOriginalInset; /** */ __weak UIScrollView *_scrollView; } #pragma mark - /** */ @property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; /** */ - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; /** */ @property (weak, nonatomic) id refreshingTarget; /** */ @property (assign, nonatomic) SEL refreshingAction; /** */ - (void)executeRefreshingCallback; #pragma mark - /** */ - (void)beginRefreshing; - (void)beginRefreshingWithCompletionBlock:(void (^)())completionBlock; /** () */ @property (copy, nonatomic) MJRefreshComponentbeginRefreshingCompletionBlock beginRefreshingCompletionBlock; /** */ @property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock; /** */ - (void)endRefreshing; - (void)endRefreshingWithCompletionBlock:(void (^)())completionBlock; /** */ - (BOOL)isRefreshing; /** */ @property (assign, nonatomic) MJRefreshState state; #pragma mark - /** scrollViewinset */ @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; /** */ @property (weak, nonatomic, readonly) UIScrollView *scrollView; #pragma mark - /** */ - (void)prepare NS_REQUIRES_SUPER; /** frame */ - (void)placeSubviews NS_REQUIRES_SUPER; /** scrollViewcontentOffset */ - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; /** scrollViewcontentSize */ - (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; /** scrollView */ - (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; #pragma mark - /** () */ @property (assign, nonatomic) CGFloat pullingPercent; /** */ @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("automaticallyChangeAlpha"); /** */ @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; @end @interface UILabel(MJRefresh) + (instancetype)mj_label; - (CGFloat)mj_textWith; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshComponent.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
662
```objective-c // // MJRefreshAutoFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshFooter.h" @interface MJRefreshAutoFooter : MJRefreshFooter /** (YES) */ @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; /** (1.0) */ @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("triggerAutomaticallyRefreshPercent"); /** (1.0) */ @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshAutoFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
122
```objective-c // : path_to_url // : path_to_url // MJRefreshFooter.m // MJRefreshExample // // Created by MJ Lee on 15/3/5. // #import "MJRefreshFooter.h" @interface MJRefreshFooter() @end @implementation MJRefreshFooter #pragma mark - + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock { MJRefreshFooter *cmp = [[self alloc] init]; cmp.refreshingBlock = refreshingBlock; return cmp; } + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action { MJRefreshFooter *cmp = [[self alloc] init]; [cmp setRefreshingTarget:target refreshingAction:action]; return cmp; } #pragma mark - - (void)prepare { [super prepare]; // self.mj_h = MJRefreshFooterHeight; // self.automaticallyHidden = NO; } - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; if (newSuperview) { // scrollView if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { if (self.isAutomaticallyHidden) { self.hidden = (totalDataCount == 0); } }]; } } } #pragma mark - - (void)endRefreshingWithNoMoreData { self.state = MJRefreshStateNoMoreData; } - (void)noticeNoMoreData { [self endRefreshingWithNoMoreData]; } - (void)resetNoMoreData { self.state = MJRefreshStateIdle; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
384
```objective-c // // MJRefreshBackGifFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackStateFooter.h" @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
117
```objective-c // // MJRefreshBackStateFooter.m // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshBackStateFooter.h" @interface MJRefreshBackStateFooter() { /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshBackStateFooter #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } - (NSString *)titleForState:(MJRefreshState)state { return self.stateTitles[@(state)]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.constraints.count) return; // self.stateLabel.frame = self.bounds; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // self.stateLabel.text = self.stateTitles[@(state)]; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
468
```objective-c // // MJRefreshBackFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackFooter.h" @interface MJRefreshBackFooter() @property (assign, nonatomic) NSInteger lastRefreshCount; @property (assign, nonatomic) CGFloat lastBottomDelta; @end @implementation MJRefreshBackFooter #pragma mark - - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; [self scrollViewContentSizeDidChange:nil]; } #pragma mark - - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; // if (self.state == MJRefreshStateRefreshing) return; _scrollViewOriginalInset = self.scrollView.contentInset; // contentOffset CGFloat currentOffsetY = self.scrollView.mj_offsetY; // offsetY CGFloat happenOffsetY = [self happenOffsetY]; // if (currentOffsetY <= happenOffsetY) return; CGFloat pullingPercent = (currentOffsetY - happenOffsetY) / self.mj_h; // pullingPercent if (self.state == MJRefreshStateNoMoreData) { self.pullingPercent = pullingPercent; return; } if (self.scrollView.isDragging) { self.pullingPercent = pullingPercent; // CGFloat normal2pullingOffsetY = happenOffsetY + self.mj_h; if (self.state == MJRefreshStateIdle && currentOffsetY > normal2pullingOffsetY) { // self.state = MJRefreshStatePulling; } else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) { // self.state = MJRefreshStateIdle; } } else if (self.state == MJRefreshStatePulling) {// && // [self beginRefreshing]; } else if (pullingPercent < 1) { self.pullingPercent = pullingPercent; } } - (void)scrollViewContentSizeDidChange:(NSDictionary *)change { [super scrollViewContentSizeDidChange:change]; // CGFloat contentHeight = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; // CGFloat scrollHeight = self.scrollView.mj_h - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom + self.ignoredScrollViewContentInsetBottom; // self.mj_y = MAX(contentHeight, scrollHeight); } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { // if (MJRefreshStateRefreshing == oldState) { [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.scrollView.mj_insetB -= self.lastBottomDelta; // if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; } completion:^(BOOL finished) { self.pullingPercent = 0.0; if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } }]; } CGFloat deltaH = [self heightForContentBreakView]; // if (MJRefreshStateRefreshing == oldState && deltaH > 0 && self.scrollView.mj_totalDataCount != self.lastRefreshCount) { self.scrollView.mj_offsetY = self.scrollView.mj_offsetY; } } else if (state == MJRefreshStateRefreshing) { // self.lastRefreshCount = self.scrollView.mj_totalDataCount; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ CGFloat bottom = self.mj_h + self.scrollViewOriginalInset.bottom; CGFloat deltaH = [self heightForContentBreakView]; if (deltaH < 0) { // view bottom -= deltaH; } self.lastBottomDelta = bottom - self.scrollView.mj_insetB; self.scrollView.mj_insetB = bottom; self.scrollView.mj_offsetY = [self happenOffsetY] + self.mj_h; } completion:^(BOOL finished) { [self executeRefreshingCallback]; }]; } } - (void)endRefreshing { dispatch_async(dispatch_get_main_queue(), ^{ self.state = MJRefreshStateIdle; }); } - (void)endRefreshingWithNoMoreData { dispatch_async(dispatch_get_main_queue(), ^{ self.state = MJRefreshStateNoMoreData; }); } #pragma mark - #pragma mark scrollView view - (CGFloat)heightForContentBreakView { CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top; return self.scrollView.contentSize.height - h; } #pragma mark contentOffset.y - (CGFloat)happenOffsetY { CGFloat deltaH = [self heightForContentBreakView]; if (deltaH > 0) { return deltaH - self.scrollViewOriginalInset.top; } else { return - self.scrollViewOriginalInset.top; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Base/MJRefreshBackFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,082
```objective-c // // MJRefreshBackGifFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackGifFooter.h" @interface MJRefreshBackGifFooter() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshBackGifFooter #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)setPullingPercent:(CGFloat)pullingPercent { [super setPullingPercent:pullingPercent]; NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; if (self.state != MJRefreshStateIdle || images.count == 0) return; [self.gifView stopAnimating]; NSUInteger index = images.count * pullingPercent; if (index >= images.count) index = images.count - 1; self.gifView.image = images[index]; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.stateLabel.hidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; self.gifView.hidden = NO; [self.gifView stopAnimating]; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateIdle) { self.gifView.hidden = NO; } else if (state == MJRefreshStateNoMoreData) { self.gifView.hidden = YES; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
804
```objective-c // // MJRefreshBackNormalFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackStateFooter.h" @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter @property (weak, nonatomic, readonly) UIImageView *arrowView; /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
87
```objective-c // // MJRefreshBackStateFooter.h // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshBackFooter.h" @interface MJRefreshBackStateFooter : MJRefreshBackFooter /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; /** statetitle */ - (NSString *)titleForState:(MJRefreshState)state; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
124
```objective-c // // MJRefreshAutoGifFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoGifFooter.h" @interface MJRefreshAutoGifFooter() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshAutoGifFooter #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.isRefreshingTitleHidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; [self.gifView stopAnimating]; self.gifView.hidden = NO; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { [self.gifView stopAnimating]; self.gifView.hidden = YES; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
685
```objective-c // // MJRefreshBackNormalFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackNormalFooter.h" #import "NSBundle+MJRefresh.h" @interface MJRefreshBackNormalFooter() { __unsafe_unretained UIImageView *_arrowView; } @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshBackNormalFooter #pragma mark - - (UIImageView *)arrowView { if (!_arrowView) { UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; [self addSubview:_arrowView = arrowView]; } return _arrowView; } - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; // CGFloat arrowCenterX = self.mj_w * 0.5; if (!self.stateLabel.hidden) { arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWith * 0.5; } CGFloat arrowCenterY = self.mj_h * 0.5; CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); // if (self.arrowView.constraints.count == 0) { self.arrowView.mj_size = self.arrowView.image.size; self.arrowView.center = arrowCenter; } // if (self.loadingView.constraints.count == 0) { self.loadingView.center = arrowCenter; } self.arrowView.tintColor = self.stateLabel.textColor; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState == MJRefreshStateRefreshing) { self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.loadingView.alpha = 0.0; } completion:^(BOOL finished) { self.loadingView.alpha = 1.0; [self.loadingView stopAnimating]; self.arrowView.hidden = NO; }]; } else { self.arrowView.hidden = NO; [self.loadingView stopAnimating]; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); }]; } } else if (state == MJRefreshStatePulling) { self.arrowView.hidden = NO; [self.loadingView stopAnimating]; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformIdentity; }]; } else if (state == MJRefreshStateRefreshing) { self.arrowView.hidden = YES; [self.loadingView startAnimating]; } else if (state == MJRefreshStateNoMoreData) { self.arrowView.hidden = YES; [self.loadingView stopAnimating]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
763
```objective-c // // MJRefreshAutoGifFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoStateFooter.h" @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
117
```objective-c // // MJRefreshAutoStateFooter.m // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshAutoStateFooter.h" @interface MJRefreshAutoStateFooter() { /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshAutoStateFooter #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } #pragma mark - - (void)stateLabelClick { if (self.state == MJRefreshStateIdle) { [self beginRefreshing]; } } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; // label self.stateLabel.userInteractionEnabled = YES; [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.constraints.count) return; // self.stateLabel.frame = self.bounds; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { self.stateLabel.text = nil; } else { self.stateLabel.text = self.stateTitles[@(state)]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
513
```objective-c // // MJRefreshAutoNormalFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoStateFooter.h" @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
74
```objective-c // // MJRefreshAutoStateFooter.h // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshAutoFooter.h" @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; /** */ @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
125
```objective-c // // MJRefreshAutoNormalFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoNormalFooter.h" @interface MJRefreshAutoNormalFooter() @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshAutoNormalFooter #pragma mark - - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; if (self.loadingView.constraints.count) return; // CGFloat loadingCenterX = self.mj_w * 0.5; if (!self.isRefreshingTitleHidden) { loadingCenterX -= self.stateLabel.mj_textWith * 0.5 + self.labelLeftInset; } CGFloat loadingCenterY = self.mj_h * 0.5; self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { [self.loadingView stopAnimating]; } else if (state == MJRefreshStateRefreshing) { [self.loadingView startAnimating]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
402
```objective-c // // MJRefreshGifHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" @interface MJRefreshGifHeader : MJRefreshStateHeader @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshGifHeader.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
113
```objective-c // // MJRefreshStateHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshHeader.h" @interface MJRefreshStateHeader : MJRefreshHeader #pragma mark - /** block */ @property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); /** label */ @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; #pragma mark - /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshStateHeader.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
150
```objective-c // // MJRefreshStateHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" @interface MJRefreshStateHeader() { /** label */ __unsafe_unretained UILabel *_lastUpdatedTimeLabel; /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshStateHeader #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } - (UILabel *)lastUpdatedTimeLabel { if (!_lastUpdatedTimeLabel) { [self addSubview:_lastUpdatedTimeLabel = [UILabel mj_label]]; } return _lastUpdatedTimeLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } #pragma mark - 9.xcurrentCalendar8.0API - (NSCalendar *)currentCalendar { if ([NSCalendar respondsToSelector:@selector(calendarWithIdentifier:)]) { return [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; } return [NSCalendar currentCalendar]; } #pragma mark key - (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey { [super setLastUpdatedTimeKey:lastUpdatedTimeKey]; // label if (self.lastUpdatedTimeLabel.hidden) return; NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey]; // block if (self.lastUpdatedTimeText) { self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime); return; } if (lastUpdatedTime) { // 1. NSCalendar *calendar = [self currentCalendar]; NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour |NSCalendarUnitMinute; NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime]; NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]]; // 2. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; BOOL isToday = NO; if ([cmp1 day] == [cmp2 day]) { // formatter.dateFormat = @" HH:mm"; isToday = YES; } else if ([cmp1 year] == [cmp2 year]) { // formatter.dateFormat = @"MM-dd HH:mm"; } else { formatter.dateFormat = @"yyyy-MM-dd HH:mm"; } NSString *time = [formatter stringFromDate:lastUpdatedTime]; // 3. self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@%@", [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], isToday ? [NSBundle mj_localizedStringForKey:MJRefreshHeaderDateTodayText] : @"", time]; } else { self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@", [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], [NSBundle mj_localizedStringForKey:MJRefreshHeaderNoneLastDateText]]; } } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderPullingText] forState:MJRefreshStatePulling]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderRefreshingText] forState:MJRefreshStateRefreshing]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.hidden) return; BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0; if (self.lastUpdatedTimeLabel.hidden) { // if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds; } else { CGFloat stateLabelH = self.mj_h * 0.5; // if (noConstrainsOnStatusLabel) { self.stateLabel.mj_x = 0; self.stateLabel.mj_y = 0; self.stateLabel.mj_w = self.mj_w; self.stateLabel.mj_h = stateLabelH; } // if (self.lastUpdatedTimeLabel.constraints.count == 0) { self.lastUpdatedTimeLabel.mj_x = 0; self.lastUpdatedTimeLabel.mj_y = stateLabelH; self.lastUpdatedTimeLabel.mj_w = self.mj_w; self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y; } } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // self.stateLabel.text = self.stateTitles[@(state)]; // key self.lastUpdatedTimeKey = self.lastUpdatedTimeKey; } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshStateHeader.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,168
```objective-c // // MJRefreshNormalHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" @interface MJRefreshNormalHeader : MJRefreshStateHeader @property (weak, nonatomic, readonly) UIImageView *arrowView; /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshNormalHeader.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
83
```objective-c // // MJRefreshNormalHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshNormalHeader.h" #import "NSBundle+MJRefresh.h" @interface MJRefreshNormalHeader() { __unsafe_unretained UIImageView *_arrowView; } @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshNormalHeader #pragma mark - - (UIImageView *)arrowView { if (!_arrowView) { UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; [self addSubview:_arrowView = arrowView]; } return _arrowView; } - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } #pragma mark - - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; // CGFloat arrowCenterX = self.mj_w * 0.5; if (!self.stateLabel.hidden) { CGFloat stateWidth = self.stateLabel.mj_textWith; CGFloat timeWidth = 0.0; if (!self.lastUpdatedTimeLabel.hidden) { timeWidth = self.lastUpdatedTimeLabel.mj_textWith; } CGFloat textWidth = MAX(stateWidth, timeWidth); arrowCenterX -= textWidth / 2 + self.labelLeftInset; } CGFloat arrowCenterY = self.mj_h * 0.5; CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); // if (self.arrowView.constraints.count == 0) { self.arrowView.mj_size = self.arrowView.image.size; self.arrowView.center = arrowCenter; } // if (self.loadingView.constraints.count == 0) { self.loadingView.center = arrowCenter; } self.arrowView.tintColor = self.stateLabel.textColor; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState == MJRefreshStateRefreshing) { self.arrowView.transform = CGAffineTransformIdentity; [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.loadingView.alpha = 0.0; } completion:^(BOOL finished) { // idle if (self.state != MJRefreshStateIdle) return; self.loadingView.alpha = 1.0; [self.loadingView stopAnimating]; self.arrowView.hidden = NO; }]; } else { [self.loadingView stopAnimating]; self.arrowView.hidden = NO; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformIdentity; }]; } } else if (state == MJRefreshStatePulling) { [self.loadingView stopAnimating]; self.arrowView.hidden = NO; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); }]; } else if (state == MJRefreshStateRefreshing) { self.loadingView.alpha = 1.0; // refreshing -> idle [self.loadingView startAnimating]; self.arrowView.hidden = YES; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshNormalHeader.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
811
```objective-c // // MJRefreshGifHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshGifHeader.h" @interface MJRefreshGifHeader() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshGifHeader #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)setPullingPercent:(CGFloat)pullingPercent { [super setPullingPercent:pullingPercent]; NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; if (self.state != MJRefreshStateIdle || images.count == 0) return; // [self.gifView stopAnimating]; // NSUInteger index = images.count * pullingPercent; if (index >= images.count) index = images.count - 1; self.gifView.image = images[index]; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; CGFloat stateWidth = self.stateLabel.mj_textWith; CGFloat timeWidth = 0.0; if (!self.lastUpdatedTimeLabel.hidden) { timeWidth = self.lastUpdatedTimeLabel.mj_textWith; } CGFloat textWidth = MAX(stateWidth, timeWidth); self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; [self.gifView stopAnimating]; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateIdle) { [self.gifView stopAnimating]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/Main/Lib/MJRefresh/Custom/Header/MJRefreshGifHeader.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
863