mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Converted to a CocoaPod
This commit is contained in:
69
Example/lottie-ios/JSONExplorerViewController.m
Normal file
69
Example/lottie-ios/JSONExplorerViewController.m
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// LAJSONExplorerViewController.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JSONExplorerViewController.h"
|
||||
|
||||
@interface JSONExplorerViewController () <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) UITableView *tableView;
|
||||
@property (nonatomic, strong) NSArray *jsonFiles;
|
||||
|
||||
@end
|
||||
|
||||
@implementation JSONExplorerViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
self.jsonFiles = [[NSBundle mainBundle] pathsForResourcesOfType:@"json" inDirectory:nil];
|
||||
|
||||
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
|
||||
[self.view addSubview:self.tableView];
|
||||
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close"
|
||||
style:UIBarButtonItemStyleDone
|
||||
target:self
|
||||
action:@selector(_closePressed)];
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews {
|
||||
[super viewWillLayoutSubviews];
|
||||
self.tableView.frame = self.view.bounds;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.jsonFiles.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
||||
NSString *fileURL = self.jsonFiles[indexPath.row];
|
||||
NSArray *components = [fileURL componentsSeparatedByString:@"/"];
|
||||
cell.textLabel.text = components.lastObject;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *fileURL = self.jsonFiles[indexPath.row];
|
||||
NSArray *components = [fileURL componentsSeparatedByString:@"/"];
|
||||
if (self.completionBlock) {
|
||||
self.completionBlock(components.lastObject);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_closePressed {
|
||||
if (self.completionBlock) {
|
||||
self.completionBlock(nil);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user