资源简介
高仿高仿喜马拉雅FM,基于Swift 3.0 编写而成,运行环境要求: Xcode 8.0
代码片段和文件信息
//
// NJKWebViewProgress.m
//
// Created by Satoshi Aasano on 4/20/13.
// Copyright (c) 2013 Satoshi Asano. All rights reserved.
//
#import “NJKWebViewProgress.h“
NSString *completeRPCURLPath = @“/njkwebviewprogressproxy/complete“;
const float NJKInitialProgressValue = 0.1f;
const float NJKInteractiveProgressValue = 0.5f;
const float NJKFinalProgressValue = 0.9f;
@implementation NJKWebViewProgress
{
NSUInteger _loadingCount;
NSUInteger _maxLoadCount;
NSURL *_currentURL;
BOOL _interactive;
}
- (id)init
{
self = [super init];
if (self) {
_maxLoadCount = _loadingCount = 0;
_interactive = NO;
}
return self;
}
- (void)startProgress
{
if (_progress < NJKInitialProgressValue) {
[self setProgress:NJKInitialProgressValue];
}
}
- (void)incrementProgress
{
float progress = self.progress;
float maxProgress = _interactive ? NJKFinalProgressValue : NJKInteractiveProgressValue;
float remainPercent = (float)_loadingCount / (float)_maxLoadCount;
float increment = (maxProgress - progress) * remainPercent;
progress += increment;
progress = fmin(progress maxProgress);
[self setProgress:progress];
}
- (void)completeProgress
{
[self setProgress:1.0];
}
- (void)setProgress:(float)progress
{
// progress should be incremental only
if (progress > _progress || progress == 0) {
_progress = progress;
if ([_progressDelegate respondsToSelector:@selector(webViewProgress:updateProgress:)]) {
[_progressDelegate webViewProgress:self updateProgress:progress];
}
if (_progressBlock) {
_progressBlock(progress);
}
}
}
- (void)reset
{
_maxLoadCount = _loadingCount = 0;
_interactive = NO;
[self setProgress:0.0];
}
#pragma mark -
#pragma mark UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if ([request.URL.path isEqualToString:completeRPCURLPath]) {
[self completeProgress];
return NO;
}
BOOL ret = YES;
if ([_webViewProxyDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) {
ret = [_webViewProxyDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
}
BOOL isFragmentJump = NO;
if (request.URL.fragment) {
NSString *nonFragmentURL = [request.URL.absoluteString stringByReplacingOccurrencesOfString:[@“#“ stringByAppendingString:request.URL.fragment] withString:@““];
isFragmentJump = [nonFragmentURL isEqualToString:webView.request.URL.absoluteString];
}
BOOL isTopLevelNavigation = [request.mainDocumentURL isEqual:request.URL];
BOOL isHTTPOrLocalFile = [request.URL.scheme isEqualToString:@“http“] || [request.URL.scheme isEqualToString:@“https“] || [request.URL.scheme isEqualToString:@“file“];
if (ret && !isFragmentJump
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-14 03:03 LXFFM-master\
文件 1419 2019-04-14 03:03 LXFFM-master\.gitignore
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcodeproj\
文件 95527 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcodeproj\project.pbxproj
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcodeproj\project.xcworkspace\
文件 150 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcodeproj\project.xcworkspace\contents.xcworkspacedata
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcworkspace\
文件 223 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM.xcworkspace\contents.xcworkspacedata
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\
文件 384 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon29x29@2x.png
文件 611 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon29x29@3x.png
文件 622 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon40x40@2x.png
文件 2979 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon60x60@2x-1.png
文件 2979 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon60x60@2x.png
文件 3702 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\AppIcon60x60@3x.png
文件 1007 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\AppIcon.appiconset\Contents.json
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\
文件 62 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\Contents.json
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\albumtag_pay.imageset\
文件 354 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\albumtag_pay.imageset\Contents.json
文件 4155 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\albumtag_pay.imageset\albumtag_pay@2x.png
文件 7272 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\albumtag_pay.imageset\albumtag_pay@3x.png
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\cell_arrow.imageset\
文件 350 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\cell_arrow.imageset\Contents.json
文件 518 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\cell_arrow.imageset\cell_arrow@2x.png
文件 284 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\cell_arrow.imageset\cell_arrow@3x.png
目录 0 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\dynamic_recommand.imageset\
文件 317 2019-04-14 03:03 LXFFM-master\LXFFM\LXFFM\Assets.xcassets\CommonIcon\dynamic_recommand.imageset\Contents.json
............此处省略796个文件信息
评论
共有 条评论