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
//
// Case6ItemView.m
// MasonryExample
//
// Created by zorro on 15/8/2.
//
#import "Case6ItemView.h"
#import "Masonry.h"
@interface Case6ItemView ()
@property (strong, nonatomic) UIView *baseView;
@property (strong, nonatomic) UIImage *image;
@property (strong, nonatomic) NSString *text;
@end
@implementation Case6ItemView
+ (instancetype)newItemWithImage:(UIImage *)image text:(NSString *)text {
Case6ItemView *item = [Case6ItemView new];
item.image = image;
item.text = text;
[item initView];
return item;
}
#pragma mark - Private methods
- (void)initView {
self.backgroundColor = [UIColor lightGrayColor];
// ImageView
UIImageView *imageView = [[UIImageView alloc] initWithImage:_image];
self.baseView = imageView;
// Label
UILabel *label = [UILabel new];
label.numberOfLines = 0;
label.text = _text;
label.textColor = [UIColor whiteColor];
[self addSubview:imageView];
[self addSubview:label];
// ImageView
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).with.offset(4);
make.top.equalTo(self.mas_top).with.offset(4);
make.right.equalTo(self.mas_right).with.offset(-4);
}];
[imageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
[imageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
// Label
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(imageView.mas_width);
make.left.equalTo(imageView.mas_left);
make.top.equalTo(imageView.mas_bottom).with.offset(4);
make.bottom.equalTo(self.mas_bottom).with.offset(-4);
}];
[label setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
}
#pragma mark - Override
// baselineview
- (UIView *)viewForBaselineLayout {
return _baseView;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/MasonryDemo/Case6ItemView.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 445 |
```objective-c
//
// Case4Cell.h
// MasonryExample
//
// Created by zorro on 15/7/31.
//
#import <UIKit/UIKit.h>
@class Case4DataEntity;
@interface Case4Cell : UITableViewCell
- (void)setupData:(Case4DataEntity *)dataEntity;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/MasonryDemo/Case4Cell.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 67 |
```objective-c
//
// JSViewController.m
// BigShow1949
//
// Created by apple on 17/7/28.
//
#import "JSViewController.h"
@implementation JSViewController
- (void)viewDidLoad {
[super viewDidLoad];
/*
JS:
1.JS URLOCUIWebView WKWebViewiOS 6UIWebView
2.WKWebView MessageHandler
3.JavaScriptCoreiOS 7
4.WebViewJavascriptBridge
5.cordovaPhoneGap
6.React Native
*/
[self setupDataArr:@[@[@"UIWebViewURL",@"JS_UIWebView_URLViewController"],
@[@"WKWebViewURL",@"JS_WKWebView_URLViewController"],
@[@"MessageHandler",@"JS_MessageHandlerViewController"],
@[@"JavaScriptCore",@"JS_JavaScriptCoreViewController"],
@[@"JSCore",@"JSCoreViewController"],
@[@"JSBridge",@"WebViewJSBridgeVC"], //
]];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JSViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 207 |
```objective-c
//
// JSViewController.h
// BigShow1949
//
// Created by apple on 17/7/28.
//
#import <UIKit/UIKit.h>
@interface JSViewController : BaseTableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JSViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 46 |
```objective-c
//
// JS_UIWebViewJSBridgeViewController.h
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <UIKit/UIKit.h>
@interface JS_UIWebViewJSBridgeViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_WebViewJSBridge/JS_UIWebViewJSBridgeViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 53 |
```objective-c
//
// JS_UIWebViewJSBridgeViewController.m
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <AVFoundation/AVFoundation.h>
#import "WebViewJavascriptBridge.h"
#import "JS_UIWebViewJSBridgeViewController.h"
@interface JS_UIWebViewJSBridgeViewController ()<UIWebViewDelegate>
@property (strong, nonatomic) UIWebView *webView;
@property WebViewJavascriptBridge *webViewBridge;
@end
@implementation JS_UIWebViewJSBridgeViewController
/*
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"UIWebView--WebViewJavascriptBridgeL";
self.view.backgroundColor = [UIColor whiteColor];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(rightClick)];
self.navigationItem.rightBarButtonItem = rightItem;
self.webView = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.webView];
NSURL *htmlURL = [[NSBundle mainBundle] URLForResource:@"index.html" withExtension:nil];
NSURLRequest *request = [NSURLRequest requestWithURL:htmlURL];
// UIWebView
self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
[self.webView loadRequest:request];
_webViewBridge = [WebViewJavascriptBridge bridgeForWebView:self.webView];
[_webViewBridge setWebViewDelegate:self];
// JS Native
[self registerNativeFunctions];
}
- (void)dealloc
{
NSLog(@"%s",__func__);
}
- (void)rightClick
{
// //
// [_webViewBridge callHandler:@"testJSFunction"];
// //
// [_webViewBridge callHandler:@"testJSFunction" data:@""];
//
[_webViewBridge callHandler:@"testJSFunction" data:@"" responseCallback:^(id responseData) {
NSLog(@"JS%@",responseData);
}];
}
#pragma mark - private method
- (void)registerNativeFunctions
{
[self registScanFunction];
[self registShareFunction];
[self registLocationFunction];
[self regitstBGColorFunction];
[self registPayFunction];
[self registShakeFunction];
}
- (void)registLocationFunction
{
[_webViewBridge registerHandler:@"locationClick" handler:^(id data, WVJBResponseCallback responseCallback) {
//
NSString *location = @"XXXX";
// js
responseCallback(location);
}];
}
- (void)registScanFunction
{
// handler JSNative
[_webViewBridge registerHandler:@"scanClick" handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"");
NSString *scanResult = @"path_to_url";
responseCallback(scanResult);
}];
}
- (void)registShareFunction
{
[_webViewBridge registerHandler:@"shareClick" handler:^(id data, WVJBResponseCallback responseCallback) {
// data JS
NSDictionary *tempDic = data;
//
NSString *title = [tempDic objectForKey:@"title"];
NSString *content = [tempDic objectForKey:@"content"];
NSString *url = [tempDic objectForKey:@"url"];
// JS
NSString *result = [NSString stringWithFormat:@":%@,%@,%@",title,content,url];
responseCallback(result);
}];
}
- (void)regitstBGColorFunction
{
__weak typeof(self) weakSelf = self;
[_webViewBridge registerHandler:@"colorClick" handler:^(id data, WVJBResponseCallback responseCallback) {
// data JS
NSDictionary *tempDic = data;
CGFloat r = [[tempDic objectForKey:@"r"] floatValue];
CGFloat g = [[tempDic objectForKey:@"g"] floatValue];
CGFloat b = [[tempDic objectForKey:@"b"] floatValue];
CGFloat a = [[tempDic objectForKey:@"a"] floatValue];
weakSelf.webView.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}];
}
- (void)registPayFunction
{
[_webViewBridge registerHandler:@"payClick" handler:^(id data, WVJBResponseCallback responseCallback) {
// data JS
NSDictionary *tempDic = data;
NSString *orderNo = [tempDic objectForKey:@"order_no"];
long long amount = [[tempDic objectForKey:@"amount"] longLongValue];
NSString *subject = [tempDic objectForKey:@"subject"];
NSString *channel = [tempDic objectForKey:@"channel"];
// ...
// JS
NSString *result = [NSString stringWithFormat:@":%@,%@,%@",orderNo,subject,channel];
responseCallback(result);
}];
}
- (void)registShakeFunction
{
[_webViewBridge registerHandler:@"shakeClick" handler:^(id data, WVJBResponseCallback responseCallback) {
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
}];
}
- (void)registGoBackFunction
{
__weak typeof(self) weakSelf = self;
[_webViewBridge registerHandler:@"goback" handler:^(id data, WVJBResponseCallback responseCallback) {
[weakSelf.webView goBack];
}];
}
//*/
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_WebViewJSBridge/JS_UIWebViewJSBridgeViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,106 |
```html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script language="javascript">
function setupWebViewJavascriptBridge(callback) {
if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
window.WVJBCallbacks = [callback];
var WVJBIframe = document.createElement('iframe');
WVJBIframe.style.display = 'none';
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
document.documentElement.appendChild(WVJBIframe);
setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}
setupWebViewJavascriptBridge(function(bridge) {
bridge.registerHandler('testJSFunction', function(data, responseCallback) {
alert('JS:'+data);
responseCallback('js');
})
})
function scanClick() {
WebViewJavascriptBridge.callHandler('scanClick', {'foo': 'bar'}, function(response) {
alert(':' + response);
document.getElementById("returnValue").value = response;
})
}
function shareClick() {
var params = {'title':'','content':'','url':'path_to_url};
WebViewJavascriptBridge.callHandler('shareClick',params,function(response) {
alert(response);
document.getElementById("returnValue").value = response;
});
}
function locationClick() {
WebViewJavascriptBridge.callHandler('locationClick',null,function(response) {
alert(response);
document.getElementById("returnValue").value = response;
});
}
function colorClick() {
var params = {'r':67,'g':20,'b':128,'a':0.5};
WebViewJavascriptBridge.callHandler('colorClick',params);
}
function payClick() {
var params = {'order_no':'201511120981234','channel':'wx','amount':1,'subject':''};
WebViewJavascriptBridge.callHandler('payClick',params,function(response) {
alert(response);
document.getElementById("returnValue").value = response;
});
}
function shake() {
WebViewJavascriptBridge.callHandler('shakeClick');
}
function goBack() {
WebViewJavascriptBridge.callHandler('goback');
}
function asyncAlert(content) {
setTimeout(function(){
alert(content);
},1);
}
</script>
</head>
<body>
<h1></h1>
<input id = 'scanBtn' type="button" value="" onclick="scanClick()"/>
<input id = 'locationBtn' type="button" value="" onclick="locationClick()" />
<input id = 'colorBtn' type="button" value="" onclick="colorClick()" />
<input id = 'shareBtn' type="button" value="" onclick="shareClick()" />
<input id = 'payBtn' type="button" value="" onclick="payClick()" />
<input id = 'shakeBtn' type="button" value="" onclick="shake()" />
<input id = 'gobackBtn' type="button" value="" onclick="goBack()" />
<h1></h1>
<input type="file" />
<h1></h1>
<textarea id ="returnValue" type="value" rows="5" cols="50">
</textarea>
<h4></h4>
<table border="1" style="width:300px;height:600px">
<tr>
<th></th>
<td>Bill Gates</td>
</tr>
<tr>
<th></th>
<td>555 77 854</td>
</tr>
<tr>
<th></th>
<td>555 77 855</td>
</tr>
</table>
</body>
</html>
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_WebViewJSBridge/index.html | html | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 858 |
```objective-c
//
// JSCoreViewController.h
// BigShow1949
//
// Created by apple on 17/6/28.
//
#import <UIKit/UIKit.h>
#import <JavaScriptCore/JavaScriptCore.h>
@interface JSCoreViewController : UIViewController
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, weak) JSContext *context;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JSCore/JSCoreViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 79 |
```objective-c
//
// JSCoreViewController.m
// BigShow1949
//
// Created by apple on 17/6/28.
//
#import "JSCoreViewController.h"
// JavaScriptCore.framework
@interface JSCoreViewController ()<UIWebViewDelegate>
@end
@implementation JSCoreViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
//webViewhtml
_webView = [[UIWebView alloc]init];
_webView.frame = CGRectMake(0, 0, YFScreen.width, YFScreen.height/2);
_webView.delegate = self;
[self.view addSubview:_webView];
//html
NSString * path = [[NSBundle mainBundle] pathForResource:@"Test.html" ofType:nil];
NSURL * url = [[NSURL alloc]initFileURLWithPath:path];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
//button,js
UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height/2, 200, 50);
btn1.backgroundColor = [UIColor blackColor];
[btn1 setTitle:@"OCJS" forState:UIControlStateNormal];
[btn1 addTarget:self action:@selector(function1) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn1];
UIButton * btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height/2+100, 200, 50);
btn2.backgroundColor = [UIColor blackColor];
[btn2 setTitle:@"OCJS()" forState:UIControlStateNormal];
[btn2 addTarget:self action:@selector(function2) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn2];
}
#pragma OCJS
-(void)function1{
[_webView stringByEvaluatingJavaScriptFromString:@"aaa()"];
}
-(void)function2{
NSString * name = @"pheromone";
NSInteger num = 520;
[_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"bbb('%@','%ld');",name,num]];
}
#pragma UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSLog(@"");
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@"");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLog(@"");
//js
_context=[webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
//htmlOC
_context[@"test1"] = ^(){
[self menthod1];
};
//htmlOC()
_context[@"test2"] = ^(){
NSArray * args = [JSContext currentArguments];//
// for (id obj in args) {
// NSLog(@"html%@",obj);
// }
NSString * name = args[0];
NSString * str = args[1];
[self menthod2:name and:str];
};
//OCJS
//1.
NSString *alertJS=@"alert('test js OC')"; //js
[_context evaluateScript:alertJS];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"");
}
#pragma JSOC
/*
, ,html(demohtml)
html,js,
*/
-(void)menthod1{
NSLog(@"JSOC, ");
self.view.backgroundColor = [UIColor blueColor];
}
-(void)menthod2:(NSString *)str1 and:(NSString *)str2{
NSLog(@"%@%@",str1,str2);
self.view.backgroundColor = [UIColor redColor];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JSCore/JSCoreViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 796 |
```html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script language="javascript">
function loadURL(url) {
var iFrame;
iFrame = document.createElement("iframe");
iFrame.setAttribute("src", url);
iFrame.setAttribute("style", "display:none;");
iFrame.setAttribute("height", "0px");
iFrame.setAttribute("width", "0px");
iFrame.setAttribute("frameborder", "0");
document.body.appendChild(iFrame);
// iFramedom
iFrame.parentNode.removeChild(iFrame);
iFrame = null;
}
function scanClick() {
alert(arr);
loadURL("haleyAction://scanClick");
}
function shareClick() {
loadURL("haleyAction://shareClick?title=&content=&url=path_to_url");
}
function locationClick() {
loadURL("haleyAction://getLocation");
}
function setLocation(location) {
asyncAlert(location);
document.getElementById("returnValue").value = location;
}
function getQRCode(result) {
asyncAlert(result);
document.getElementById("returnValue").value = result;
}
function colorClick() {
loadURL("haleyAction://setColor?r=67&g=205&b=128&a=0.5");
}
function payClick() {
loadURL("haleyAction://payAction?order_no=201511120981234&channel=wx&amount=1&subject=");
}
function payResult(str,code) {
var content = str + ", " + code;
asyncAlert(content);
document.getElementById("returnValue").value = content;
}
<!-- function payResult(str) {-->
<!-- var content = str;-->
<!-- asyncAlert(content);-->
<!-- document.getElementById("returnValue").value = content;-->
<!-- }-->
function shareResult(channel_id,share_channel,share_url) {
var content = channel_id+","+share_channel+","+share_url;
asyncAlert(content);
document.getElementById("returnValue").value = content;
}
function shake() {
loadURL("haleyAction://shake");
}
function goBack() {
loadURL("haleyAction://back");
}
function asyncAlert(content) {
setTimeout(function(){
alert(content);
},1);
}
</script>
</head>
<body>
<h1></h1>
<input type="button" value="" onclick="scanClick()" />
<input type="button" value="" onclick="locationClick()" />
<input type="button" value="" onclick="colorClick()" />
<input type="button" value="" onclick="shareClick()" />
<input type="button" value="" onclick="payClick()" />
<input type="button" value="" onclick="shake()" />
<input type="button" value="" onclick="goBack()" />
<h1></h1>
<input type="file" />
<h1></h1>
<textarea id ="returnValue" type="value" rows="5" cols="50">
</textarea>
<h4></h4>
<table border="1" style="width:300px;height:600px">
<tr>
<th></th>
<td>Bill Gates</td>
</tr>
<tr>
<th></th>
<td>555 77 854</td>
</tr>
<tr>
<th></th>
<td>555 77 855</td>
</tr>
</table>
</body>
</html>
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_URL/JS_URL.html | html | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 803 |
```objective-c
//
// JS_URLViewController.m
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <AVFoundation/AVFoundation.h>
#import "JS_UIWebView_URLViewController.h"
@interface JS_UIWebView_URLViewController ()<UIWebViewDelegate>
@property (strong, nonatomic) UIWebView *webView;
@end
@implementation JS_UIWebView_URLViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"UIWebViewURL";
self.view.backgroundColor = [UIColor whiteColor];
self.webView = [[UIWebView alloc] initWithFrame:self.view.frame];
self.webView.delegate = self;
NSURL *htmlURL = [[NSBundle mainBundle] URLForResource:@"JS_URL.html" withExtension:nil];
// NSURL *htmlURL = [NSURL URLWithString:@"path_to_url"];
NSURLRequest *request = [NSURLRequest requestWithURL:htmlURL];
// webView
self.webView.scrollView.bounces = NO;
// UIWebView
self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
[self.webView loadRequest:request];
[self.view addSubview:self.webView];
}
#pragma mark - private method
- (void)handleCustomAction:(NSURL *)URL
{
NSString *host = [URL host];
if ([host isEqualToString:@"scanClick"]) {
NSLog(@"");
} else if ([host isEqualToString:@"shareClick"]) {
[self share:URL];
} else if ([host isEqualToString:@"getLocation"]) {
[self getLocation];
} else if ([host isEqualToString:@"setColor"]) {
[self changeBGColor:URL];
} else if ([host isEqualToString:@"payAction"]) {
[self payAction:URL];
} else if ([host isEqualToString:@"shake"]) {
[self shakeAction];
} else if ([host isEqualToString:@"goBack"]) {
[self goBack];
}
}
- (void)getLocation
{
//
// js
NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",@"XXXX"];
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
}
- (void)share:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
NSString *title = [tempDic objectForKey:@"title"];
NSString *content = [tempDic objectForKey:@"content"];
NSString *url = [tempDic objectForKey:@"url"];
//
// js
NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@','%@','%@')",title,content,url];
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
}
- (void)changeBGColor:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
CGFloat r = [[tempDic objectForKey:@"r"] floatValue];
CGFloat g = [[tempDic objectForKey:@"g"] floatValue];
CGFloat b = [[tempDic objectForKey:@"b"] floatValue];
CGFloat a = [[tempDic objectForKey:@"a"] floatValue];
self.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}
- (void)payAction:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
// NSString *orderNo = [tempDic objectForKey:@"order_no"];
// long long amount = [[tempDic objectForKey:@"amount"] longLongValue];
// NSString *subject = [tempDic objectForKey:@"subject"];
// NSString *channel = [tempDic objectForKey:@"channel"];
//
// js
NSUInteger code = 1;
NSString *jsStr = [NSString stringWithFormat:@"payResult('%@',%lu)",@"",(unsigned long)code];
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
}
- (void)shakeAction
{
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
}
- (void)goBack
{
[self.webView goBack];
}
#pragma mark - UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *URL = request.URL;
NSString *scheme = [URL scheme];
NSLog(@"URL = %@", URL);
if ([scheme isEqualToString:@"haleyaction"]) {
[self handleCustomAction:URL];
return NO;
}
return YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:@"var arr = [3, 4, 'abc'];"];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_URL/JS_UIWebView_URLViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,265 |
```objective-c
//
// JS_WKWebView_URLViewController.h
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <UIKit/UIKit.h>
@interface JS_WKWebView_URLViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_URL/JS_WKWebView_URLViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 53 |
```objective-c
//
// JS_WKWebView_URLViewController.m
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <WebKit/WebKit.h>
#import <AVFoundation/AVFoundation.h>
#import "JS_WKWebView_URLViewController.h"
@interface JS_WKWebView_URLViewController ()<WKNavigationDelegate,WKUIDelegate>
@property (strong, nonatomic) WKWebView *webView;
@property (strong, nonatomic) UIProgressView *progressView;
@end
// iOS8
@implementation JS_WKWebView_URLViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"WKWebViewURL";
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(rightClick)];
self.navigationItem.rightBarButtonItem = rightItem;
[self initWKWebView];
[self initProgressView];
[self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)initWKWebView
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.userContentController = [WKUserContentController new];
WKPreferences *preferences = [WKPreferences new];
preferences.javaScriptCanOpenWindowsAutomatically = YES;
preferences.minimumFontSize = 30.0;
configuration.preferences = preferences;
self.webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
// NSString *urlStr = @"path_to_url";
// NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
// [self.webView loadRequest:request];
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"JS_URL.html" ofType:nil];
NSURL *fileURL = [NSURL fileURLWithPath:urlStr];
[self.webView loadFileURL:fileURL allowingReadAccessToURL:fileURL];
self.webView.navigationDelegate = self;
self.webView.UIDelegate = self;
[self.view addSubview:self.webView];
}
- (void)initProgressView
{
CGFloat kScreenWidth = [[UIScreen mainScreen] bounds].size.width;
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 2)];
progressView.tintColor = [UIColor redColor];
progressView.trackTintColor = [UIColor lightGrayColor];
[self.view addSubview:progressView];
self.progressView = progressView;
}
- (void)rightClick
{
[self goBack];
}
- (void)dealloc
{
NSLog(@"%s",__FUNCTION__);
[self.webView removeObserver:self forKeyPath:@"estimatedProgress"];
}
#pragma mark - private method
- (void)handleCustomAction:(NSURL *)URL
{
NSString *host = [URL host];
if ([host isEqualToString:@"scanClick"]) {
NSLog(@"");
} else if ([host isEqualToString:@"shareClick"]) {
[self share:URL];
} else if ([host isEqualToString:@"getLocation"]) {
[self getLocation];
} else if ([host isEqualToString:@"setColor"]) {
[self changeBGColor:URL];
} else if ([host isEqualToString:@"payAction"]) {
[self payAction:URL];
} else if ([host isEqualToString:@"shake"]) {
[self shakeAction];
} else if ([host isEqualToString:@"goBack"]) {
[self goBack];
}
}
- (void)getLocation
{
//
// js
NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",@"XXXX"];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)share:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
NSString *title = [tempDic objectForKey:@"title"];
NSString *content = [tempDic objectForKey:@"content"];
NSString *url = [tempDic objectForKey:@"url"];
//
// js
NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@','%@','%@')",title,content,url];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)changeBGColor:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
CGFloat r = [[tempDic objectForKey:@"r"] floatValue];
CGFloat g = [[tempDic objectForKey:@"g"] floatValue];
CGFloat b = [[tempDic objectForKey:@"b"] floatValue];
CGFloat a = [[tempDic objectForKey:@"a"] floatValue];
self.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}
- (void)payAction:(NSURL *)URL
{
NSArray *params =[URL.query componentsSeparatedByString:@"&"];
NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
for (NSString *paramStr in params) {
NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
if (dicArray.count > 1) {
NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[tempDic setObject:decodeValue forKey:dicArray[0]];
}
}
// NSString *orderNo = [tempDic objectForKey:@"order_no"];
// long long amount = [[tempDic objectForKey:@"amount"] longLongValue];
// NSString *subject = [tempDic objectForKey:@"subject"];
// NSString *channel = [tempDic objectForKey:@"channel"];
//
// js
NSString *jsStr = [NSString stringWithFormat:@"payResult('%@')",@""];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)shakeAction
{
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
}
- (void)goBack
{
[self.webView goBack];
}
#pragma mark - KVO
// wkWebView
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == self.webView && [keyPath isEqualToString:@"estimatedProgress"]) {
CGFloat newprogress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue];
if (newprogress == 1) {
[self.progressView setProgress:1.0 animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.progressView.hidden = YES;
[self.progressView setProgress:0 animated:NO];
});
}else {
self.progressView.hidden = NO;
[self.progressView setProgress:newprogress animated:YES];
}
}
}
#pragma mark - WKNavigationDelegate
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
/*
decisionHandlerblockapp blockWKNavigationActionPolicyCancelUIWebViewreturn NOWKNavigationActionPolicyAllowUIWebView return YES
*/
NSURL *URL = navigationAction.request.URL;
NSString *scheme = [URL scheme];
if ([scheme isEqualToString:@"haleyaction"]) {
[self handleCustomAction:URL];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
decisionHandler(WKNavigationActionPolicyAllow);
}
#pragma mark - WKUIDelegate
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
/*
WKWebViewalertconfirm WKWebViewWKUIDelegate
JSalert alert
completionHandlerblock
*/
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
completionHandler();
}]];
[self presentViewController:alert animated:YES completion:nil];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_URL/JS_WKWebView_URLViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,966 |
```objective-c
//
// JS_URLViewController.h
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <UIKit/UIKit.h>
@interface JS_UIWebView_URLViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_URL/JS_UIWebView_URLViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 49 |
```objective-c
//
// WebViewJavascriptBridgeVC.h
// BigShow1949
//
// Created by apple on 17/7/28.
//
#import <UIKit/UIKit.h>
@interface WebViewJSBridgeVC : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/WebViewJSBridgeVC.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 48 |
```html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<title></title>
</head>
<body onload="onLoaded()">
<div class="title">
iOS1iOS
</div>
<div class="subtitle">
2017.05.08 17:23 1640 64 2 5
</div>
<div class="text">
,frame ()
</div>
<div class="image">
<img img-index="0" img-src="path_to_url" onclick="onImageClicked(0)"/>
</div>
<div class="text">
</div>
<div class="text">
1frame; frameceil0UITableViewCell
</div>
<div class="text">
2UI@2x@3x;
</div>
<div class="text">
</div>
<div class="image">
<img img-index="1" img-src="path_to_url" onclick="onImageClicked(1)" src=""/>
</div>
<div id="moredetail">
<span></span>
<a class="detailpage" href="path_to_url">iOS1iOS</a>
</div>
<script src="./content1.js"></script>
<link rel="stylesheet" href="./content1.css">
</body>
</html>
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/content1.html | html | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 343 |
```javascript
//URL(js oc)
function setupWebViewJavascriptBridge(callback) {
if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
window.WVJBCallbacks = [callback];
var WVJBIframe = document.createElement('iframe');
WVJBIframe.style.display = 'none';
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
document.documentElement.appendChild(WVJBIframe);
setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
};
function onLoaded(){
// alert('onLoaded');
var allImage = document.querySelectorAll("img");
allImage = Array.prototype.slice.call(allImage, 0);
var imageInfos = new Array();
allImage.forEach(function(image) {
var imageSrc = image.getAttribute("img-src");
var imageIndex = image.getAttribute("img-index");
imageInfos.push(new Array(imageIndex,imageSrc));
});
//OConLoaded
WebViewJavascriptBridge.callHandler('onLoaded',imageInfos, function(response){
})
};
function onImageClicked(imageIndex) {
var image = getImageAtIndex(imageIndex);
x = image.getBoundingClientRect().left;
y = image.getBoundingClientRect().top;
x = x + document.documentElement.scrollLeft;
y = y + document.documentElement.scrollTop;
width = image.width;
height = image.height;
var array = new Array(imageIndex,x,y,width,height);
// var dic = {'index':index,'x':x,'y':y,'width':width,'height':height}
// alert('x=' + x + ',y=' + y + ',width=' + width + ',height=' + height);
// alert(array);
WebViewJavascriptBridge.callHandler('browImage',array, function(response){
})
};
//OCJS
setupWebViewJavascriptBridge(function(bridge) {
bridge.registerHandler('imageDownLoadCompleted', function(data, responseCallback) {
// alert('index = ' + data[0] + 'filepath = ' + data[1]);
image = getImageAtIndex(data[0])
image.src = data[1];
});
});
//
function getImageAtIndex(imageIndex){
var allImage = document.querySelectorAll("img");
allImage = Array.prototype.slice.call(allImage, 0);
image = allImage[imageIndex]
return image;
};
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/content1.js | javascript | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 534 |
```objective-c
//
// WebViewJavascriptBridgeVC.m
// BigShow1949
//
// Created by apple on 17/7/28.
//
#import "WebViewJSBridgeVC.h"
#import "WebViewJavascriptBridge.h"
#import "EXTScope.h"
#import "SDWebImageManager.h"
static NSString * const onLoadedMethodJSName = @"onLoaded";
static NSString * const browImageMethodJSName = @"browImage";
static NSString * const imageDownLoadCompletedJSName = @"imageDownLoadCompleted";
@interface WebViewJSBridgeVC ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) WebViewJavascriptBridge *bridge;
@property (nonatomic, strong) NSMutableArray *imageFilePaths;
@end
/* ============ WebViewJavascriptBridge ==========*/
@implementation WebViewJSBridgeVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setEdgesForExtendedLayout:UIRectEdgeNone];
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"JSBridgeVC";
NSString *htmlFilePath = [[NSBundle mainBundle]pathForResource:@"content1" ofType:@"html"];
NSString *htmlContentString = [NSString stringWithContentsOfFile:htmlFilePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:htmlContentString baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[self.view addSubview:self.webView];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_back"] style:UIBarButtonItemStylePlain target:self action:@selector(onBackAction)];
}
- (void)onBackAction{
if([_webView canGoBack]){
[_webView goBack];
}
else{
[self.navigationController popViewControllerAnimated:YES];
}
}
- (UIWebView *)webView{
if (!_webView) {
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, YFScreen.width, YFScreen.height - 64)];
_webView.layer.borderColor = [UIColor redColor].CGColor;
_webView.layer.borderWidth = 1;
}
return _webView;
}
- (WebViewJavascriptBridge *)bridge{
if (!_bridge) {
// [WebViewJavascriptBridge enableLogging];
// ,
// _bridge = [WebViewJavascriptBridge bridgeForWebView:self.webView];
// [_bridge setWebViewDelegate:self];
}
return _bridge;
}
/**
NativeJS
*/
/*
- (void)registerNativeHandler{
//
@weakify(self);
[self.bridge registerHandler:onLoadedMethodJSName handler:^(NSArray *imageInfos, WVJBResponseCallback responseCallback) {
//js
NSLog(@"imageInfos = %@", imageInfos);
@strongify(self);
[self downloadImagesWithInfos:imageInfos];
}];
//
[self.bridge registerHandler:browImageMethodJSName handler:^(NSArray *dataArray, WVJBResponseCallback responseCallback) {
@strongify(self);
NSLog(@"dataArray = %@", dataArray);
NSInteger index = [dataArray[0] integerValue];
// XLPhotoBrowser *imageBrowser = [XLPhotoBrowser showPhotoBrowserWithCurrentImageIndex:index imageCount:[self.imageFilePaths count] datasource:self];
// imageBrowser.browserStyle = XLPhotoBrowserStyleSimple;
}];
}
*/
/**
js
*/
/*
- (void)downloadImagesWithInfos:(NSArray *)imageInfos{
[imageInfos enumerateObjectsUsingBlock:^(NSArray *info, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *imageCachePath = [[SDImageCache sharedImageCache] defaultCachePathForKey:info[1]];
[self.imageFilePaths addObject:imageCachePath];
}];
for (int i = 0; i < [imageInfos count]; i++) {
NSArray *imageInfo = [imageInfos objectAtIndex:i];
NSUInteger imageIndex = [imageInfo[0] integerValue];
[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:imageInfo[1]] options:SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (!image) {
return;
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *imageCachePath = [[SDImageCache sharedImageCache] defaultCachePathForKey:[imageURL absoluteString]];
//jsimagesDownloadComplete
[self.bridge callHandler:imageDownLoadCompletedJSName data:@[[NSNumber numberWithInteger:imageIndex],imageCachePath] responseCallback:nil];
});
}];
}
}
*/
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/WebViewJSBridgeVC.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 989 |
```css
body {
background-color: #fff;
margin-left:15px;
margin-right: 15px;
text-align: justify;
}
/**/
.clearfix:after {
content:".";
display:block;
height:0;
visibility:hidden;
clear:both;
}
div.title {
color: #000000;
font-size: 25px;
margin-top: 20px;
line-height:30px;
font-weight:bold;
}
div.subtitle {
color: #c6c6c6;
font-size: 13px;
margin-top: 10px;
}
div.text {
margin-top: 10px;
color: #333;
font-size: 16px;
line-height: 28px;
text-indent: 32px;
}
div.image img {
width: 100%;
vertical-align:bottom;
display: block;
overflow: hidden;
margin-top: 10px;
background: #e6e6e6;
background-repeat: no-repeat;
background-size: 100% auto;
-webkit-user-select: none;
border-style: outset;
border-width: thick;
}
#moredetail{
text-align:left;
margin:20px 0 15px 0;
}
.detailpage {
display: inline-block;
text-decoration: inherit;
font-size:15px;
padding:10px;
background:#e1e1e1;
color:#333333;
margin-right: 10px;
margin-bottom: 12px;
border-radius: 4px;
}
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/content1.css | css | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 351 |
```objective-c
//
// EXTSelectorChecking.h
// extobjc
//
// Created by Justin Spahr-Summers on 26.06.12.
// Released under the MIT license.
//
#import <Foundation/Foundation.h>
#import "metamacros.h"
/**
* \@checkselector verifies at compile-time that a selector can be invoked
* against the given TARGET. The checked selector is then returned as a SEL.
*
* The variadic arguments should be pieces of the selector, each ending with
* ':'. For example:
*
* @code
[myButton addTarget:self action:@checkselector(self, buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[otherButton addTarget:self action:@checkselector(self, buttonAction:, withEvent:) forControlEvents:UIControlEventTouchUpInside];
* @endcode
*
* For zero-argument selectors, use \@checkselector0 instead.
*
* @bug This macro currently does not work with selectors with variadic
* arguments.
*
* @bug This macro will not work if the method on TARGET designated by the
* selector must accept a struct or union argument.
*/
#define checkselector(TARGET, ...) \
(((void)(NO && ((void)[TARGET metamacro_foreach(ext_checkselector_message_iter,, __VA_ARGS__)], NO)), \
metamacro_foreach(ext_checkselector_selector_iter,, __VA_ARGS__))).ext_toSelector
#define checkselector0(TARGET, SELECTOR) \
(((void)(NO && ((void)[TARGET SELECTOR], NO)), \
# SELECTOR)).ext_toSelector
/*** implementation details follow ***/
#define ext_checkselector_message_iter(INDEX, SELPART) \
SELPART (0)
#define ext_checkselector_selector_iter(INDEX, SELPART) \
# SELPART
@interface NSString (EXTCheckedSelectorAdditions)
- (SEL)ext_toSelector;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/extobjc/EXTSelectorChecking.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 374 |
```objective-c
//
// EXTKeyPathCoding.h
// extobjc
//
// Created by Justin Spahr-Summers on 19.06.12.
// Released under the MIT license.
//
#import <Foundation/Foundation.h>
#import "metamacros.h"
/**
* \@keypath allows compile-time verification of key paths. Given a real object
* receiver and key path:
*
* @code
NSString *UTF8StringPath = @keypath(str.lowercaseString.UTF8String);
// => @"lowercaseString.UTF8String"
NSString *versionPath = @keypath(NSObject, version);
// => @"version"
NSString *lowercaseStringPath = @keypath(NSString.new, lowercaseString);
// => @"lowercaseString"
* @endcode
*
* ... the macro returns an \c NSString containing all but the first path
* component or argument (e.g., @"lowercaseString.UTF8String", @"version").
*
* In addition to simply creating a key path, this macro ensures that the key
* path is valid at compile-time (causing a syntax error if not), and supports
* refactoring, such that changing the name of the property will also update any
* uses of \@keypath.
*/
#define keypath(...) \
metamacro_if_eq(1, metamacro_argcount(__VA_ARGS__))(keypath1(__VA_ARGS__))(keypath2(__VA_ARGS__))
#define keypath1(PATH) \
(((void)(NO && ((void)PATH, NO)), strchr(# PATH, '.') + 1))
#define keypath2(OBJ, PATH) \
(((void)(NO && ((void)OBJ.PATH, NO)), # PATH))
/**
* \@collectionKeypath allows compile-time verification of key paths across collections NSArray/NSSet etc. Given a real object
* receiver, collection object receiver and related keypaths:
*
* @code
NSString *employessFirstNamePath = @collectionKeypath(department.employees, Employee.new, firstName)
// => @"employees.firstName"
NSString *employessFirstNamePath = @collectionKeypath(Department.new, employees, Employee.new, firstName)
// => @"employees.firstName"
* @endcode
*
*/
#define collectionKeypath(...) \
metamacro_if_eq(3, metamacro_argcount(__VA_ARGS__))(collectionKeypath3(__VA_ARGS__))(collectionKeypath4(__VA_ARGS__))
#define collectionKeypath3(PATH, COLLECTION_OBJECT, COLLECTION_PATH) ([[NSString stringWithFormat:@"%s.%s",keypath(PATH), keypath(COLLECTION_OBJECT, COLLECTION_PATH)] UTF8String])
#define collectionKeypath4(OBJ, PATH, COLLECTION_OBJECT, COLLECTION_PATH) ([[NSString stringWithFormat:@"%s.%s",keypath(OBJ, PATH), keypath(COLLECTION_OBJECT, COLLECTION_PATH)] UTF8String])
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/extobjc/EXTKeyPathCoding.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 594 |
```objective-c
//
// EXTScope.h
// extobjc
//
// Created by Justin Spahr-Summers on 2011-05-04.
// Released under the MIT license.
//
#import "metamacros.h"
/**
* \@onExit defines some code to be executed when the current scope exits. The
* code must be enclosed in braces and terminated with a semicolon, and will be
* executed regardless of how the scope is exited, including from exceptions,
* \c goto, \c return, \c break, and \c continue.
*
* Provided code will go into a block to be executed later. Keep this in mind as
* it pertains to memory management, restrictions on assignment, etc. Because
* the code is used within a block, \c return is a legal (though perhaps
* confusing) way to exit the cleanup block early.
*
* Multiple \@onExit statements in the same scope are executed in reverse
* lexical order. This helps when pairing resource acquisition with \@onExit
* statements, as it guarantees teardown in the opposite order of acquisition.
*
* @note This statement cannot be used within scopes defined without braces
* (like a one line \c if). In practice, this is not an issue, since \@onExit is
* a useless construct in such a case anyways.
*/
#define onExit \
autoreleasepool {} \
__strong rac_cleanupBlock_t metamacro_concat(rac_exitBlock_, __LINE__) __attribute__((cleanup(rac_executeCleanupBlock), unused)) = ^
/**
* Creates \c __weak shadow variables for each of the variables provided as
* arguments, which can later be made strong again with #strongify.
*
* This is typically used to weakly reference variables in a block, but then
* ensure that the variables stay alive during the actual execution of the block
* (if they were live upon entry).
*
* See #strongify for an example of usage.
*/
#define weakify(...) \
autoreleasepool {} \
metamacro_foreach_cxt(rac_weakify_,, __weak, __VA_ARGS__)
/**
* Like #weakify, but uses \c __unsafe_unretained instead, for targets or
* classes that do not support weak references.
*/
#define unsafeify(...) \
autoreleasepool {} \
metamacro_foreach_cxt(rac_weakify_,, __unsafe_unretained, __VA_ARGS__)
/**
* Strongly references each of the variables provided as arguments, which must
* have previously been passed to #weakify.
*
* The strong references created will shadow the original variable names, such
* that the original names can be used without issue (and a significantly
* reduced risk of retain cycles) in the current scope.
*
* @code
id foo = [[NSObject alloc] init];
id bar = [[NSObject alloc] init];
@weakify(foo, bar);
// this block will not keep 'foo' or 'bar' alive
BOOL (^matchesFooOrBar)(id) = ^ BOOL (id obj){
// but now, upon entry, 'foo' and 'bar' will stay alive until the block has
// finished executing
@strongify(foo, bar);
return [foo isEqual:obj] || [bar isEqual:obj];
};
* @endcode
*/
#define strongify(...) \
try {} @finally {} \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
metamacro_foreach(rac_strongify_,, __VA_ARGS__) \
_Pragma("clang diagnostic pop")
/*** implementation details follow ***/
typedef void (^rac_cleanupBlock_t)();
static inline void rac_executeCleanupBlock (__strong rac_cleanupBlock_t *block) {
(*block)();
}
#define rac_weakify_(INDEX, CONTEXT, VAR) \
CONTEXT __typeof__(VAR) metamacro_concat(VAR, _weak_) = (VAR);
#define rac_strongify_(INDEX, VAR) \
__strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_);
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/extobjc/EXTScope.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 858 |
```objective-c
//
// EXTSelectorChecking.m
// extobjc
//
// Created by Justin Spahr-Summers on 26.06.12.
// Released under the MIT license.
//
#import "EXTSelectorChecking.h"
@implementation NSString (EXTCheckedSelectorAdditions)
- (SEL)ext_toSelector {
return NSSelectorFromString(self);
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/extobjc/EXTSelectorChecking.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 77 |
```objective-c
//
// JS_JavaScriptCoreViewController.h
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <UIKit/UIKit.h>
@interface JS_JavaScriptCoreViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_JavaScriptCore/JS_JavaScriptCoreViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 53 |
```html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script language="javascript">
function scanClick() {
scan();
}
function shareClick() {
share('','','url=path_to_url
}
function locationClick() {
getLocation();
}
function setLocation(location) {
asyncAlert(location);
document.getElementById("returnValue").value = location;
}
function getQRCode(result) {
asyncAlert(result);
document.getElementById("returnValue").value = result;
}
function colorClick() {
setColor(67,205,12,0.5);
}
function payClick() {
payAction('201511120981234','wx',1,'');
}
function payResult(str) {
asyncAlert(str);
document.getElementById("returnValue").value = str;
}
function shareResult(channel_id,share_channel,share_url) {
var content = channel_id+","+share_channel+","+share_url;
asyncAlert(content);
document.getElementById("returnValue").value = content;
}
function shake() {
shake();
}
function goBack() {
goBack();
}
function showArr(){
asyncAlert(arr);
}
function asyncAlert(content) {
setTimeout(function(){
alert(content);
},1);
}
</script>
</head>
<body>
<h1></h1>
<input type="button" value="" onclick="scanClick()" />
<input type="button" value="" onclick="locationClick()" />
<input type="button" value="" onclick="colorClick()" />
<input type="button" value="" onclick="shareClick()" />
<input type="button" value="" onclick="payClick()" />
<input type="button" value="" onclick="shake()" />
<input type="button" value="" onclick="goBack()" />
<input type="button" value="arr" onclick="showArr()" />
<h1></h1>
<input type="file" />
<h1></h1>
<textarea id ="returnValue" type="value" rows="5" cols="50">
</textarea>
<h4></h4>
<table border="1" style="width:300px;height:600px">
<tr>
<th></th>
<td>Bill Gates</td>
</tr>
<tr>
<th></th>
<td>555 77 854</td>
</tr>
<tr>
<th></th>
<td>555 77 855</td>
</tr>
</table>
</body>
</html>
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_JavaScriptCore/JS_JavaScriptCore.html | html | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 602 |
```objective-c
//
// JS_JavaScriptCoreViewController.m
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <AVFoundation/AVFoundation.h>
#import <JavaScriptCore/JavaScriptCore.h>
#import "JS_JavaScriptCoreViewController.h"
@interface JS_JavaScriptCoreViewController ()<UIWebViewDelegate>
@property (strong, nonatomic) UIWebView *webView;
@end
@implementation JS_JavaScriptCoreViewController
- (void)viewDidLoad {
[super viewDidLoad];
// OCJS, 80
self.title = @"UIWebView-JavaScriptCore";
self.view.backgroundColor = [UIColor whiteColor];
self.webView = [[UIWebView alloc] initWithFrame:self.view.frame];
self.webView.delegate = self;
NSURL *htmlURL = [[NSBundle mainBundle] URLForResource:@"JS_JavaScriptCore.html" withExtension:nil];
// NSURL *htmlURL = [NSURL URLWithString:@"path_to_url"];
NSURLRequest *request = [NSURLRequest requestWithURL:htmlURL];
self.webView.backgroundColor = [UIColor clearColor];
// UIWebView
self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
[self.webView loadRequest:request];
[self.view addSubview:self.webView];
}
- (void)dealloc
{
NSLog(@"dealloc ======== %s",__func__);
}
#pragma mark - private method
- (void)addCustomActions
{
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
[context evaluateScript:@"var arr = [3, 4, 'abc'];"];
[self addScanWithContext:context];
[self addLocationWithContext:context];
[self addSetBGColorWithContext:context];
[self addShareWithContext:context];
[self addPayActionWithContext:context];
[self addShakeActionWithContext:context];
[self addGoBackWithContext:context];
}
- (void)addScanWithContext:(JSContext *)context
{
context[@"scan"] = ^() {
NSLog(@"");
};
}
//
- (void)addLocationWithContext:(JSContext *)context
{
context[@"getLocation"] = ^() {
// js 1
NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",@"XXXX"];
[[JSContext currentContext] evaluateScript:jsStr];
};
}
- (void)addShareWithContext:(JSContext *)context
{
context[@"share"] = ^() {
NSArray *args = [JSContext currentArguments];
if (args.count < 3) {
return ;
}
NSString *title = [args[0] toString];
NSString *content = [args[1] toString];
NSString *url = [args[2] toString];
//
// js
NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@','%@','%@')",title,content,url];
[[JSContext currentContext] evaluateScript:jsStr];
};
}
- (void)addSetBGColorWithContext:(JSContext *)context
{
__weak typeof(self) weakSelf = self;
context[@"setColor"] = ^() {
NSArray *args = [JSContext currentArguments];
if (args.count < 4) {
return ;
}
CGFloat r = [[args[0] toNumber] floatValue];
CGFloat g = [[args[1] toNumber] floatValue];
CGFloat b = [[args[2] toNumber] floatValue];
CGFloat a = [[args[3] toNumber] floatValue];
weakSelf.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
};
}
- (void)addPayActionWithContext:(JSContext *)context
{
context[@"payAction"] = ^() {
NSArray *args = [JSContext currentArguments];
if (args.count < 4) {
return ;
}
NSString *orderNo = [args[0] toString];
NSString *channel = [args[1] toString];
long long amount = [[args[2] toNumber] longLongValue];
NSString *subject = [args[3] toString];
//
NSLog(@"orderNo:%@---channel:%@---amount:%lld---subject:%@",orderNo,channel,amount,subject);
// js
// NSString *jsStr = [NSString stringWithFormat:@"payResult('%@')",@""];
// [[JSContext currentContext] evaluateScript:jsStr];
// js 2
[[JSContext currentContext][@"payResult"] callWithArguments:@[@""]];
// 3
// NSString *jsStr = [NSString stringWithFormat:@"payResult('%@')",@""];
// [weakSelf.webView stringByEvaluatingJavaScriptFromString:jsStr];
};
}
- (void)addShakeActionWithContext:(JSContext *)context
{
context[@"shake"] = ^() {
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
};
}
- (void)addGoBackWithContext:(JSContext *)context
{
__weak typeof(self) weakSelf = self;
context[@"goBack"] = ^() {
[weakSelf.webView goBack];
};
}
#pragma mark - UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"webViewDidFinishLoad");
[self addCustomActions];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_JavaScriptCore/JS_JavaScriptCoreViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,181 |
```objective-c
//
// JS_MessageHandlerViewController.h
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <UIKit/UIKit.h>
@interface JS_MessageHandlerViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_MessageHandler/JS_MessageHandlerViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 49 |
```objective-c
//
// JS_MessageHandlerViewController.m
// BigShow1949
//
// Created by on 2018/3/24.
//
#import <WebKit/WebKit.h>
#import <AVFoundation/AVFoundation.h>
#import "JS_MessageHandlerViewController.h"
#import "HLAudioPlayer.h"
@interface JS_MessageHandlerViewController ()<WKUIDelegate,WKScriptMessageHandler>
@property (strong, nonatomic) WKWebView *webView;
@property (strong, nonatomic) UIProgressView *progressView;
@end
@implementation JS_MessageHandlerViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"MessageHandler";
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(rightClick)];
self.navigationItem.rightBarButtonItem = rightItem;
[self initWKWebView];
[self initProgressView];
[self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// addScriptMessageHandler
// WKWebView,WKWebView copy(configuration configuration copy userContentController
// userContentController self
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"ScanAction"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"Location"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"Share"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"Color"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"Pay"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"Shake"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"GoBack"];
[self.webView.configuration.userContentController addScriptMessageHandler:self name:@"PlaySound"];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// handlers
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"ScanAction"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"Location"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"Share"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"Color"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"Pay"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"Shake"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"GoBack"];
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"PlaySound"];
}
- (void)initWKWebView
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
WKPreferences *preferences = [WKPreferences new];
preferences.javaScriptCanOpenWindowsAutomatically = YES;
preferences.minimumFontSize = 40.0;
configuration.preferences = preferences;
self.webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
// NSString *urlStr = @"path_to_url";
// NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
// [self.webView loadRequest:request];
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"JS_MessageHandler.html" ofType:nil];
NSURL *fileURL = [NSURL fileURLWithPath:urlStr];
[self.webView loadFileURL:fileURL allowingReadAccessToURL:fileURL];
self.webView.UIDelegate = self;
[self.view addSubview:self.webView];
}
- (void)initProgressView
{
CGFloat kScreenWidth = [[UIScreen mainScreen] bounds].size.width;
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 2)];
progressView.tintColor = [UIColor redColor];
progressView.trackTintColor = [UIColor lightGrayColor];
[self.view addSubview:progressView];
self.progressView = progressView;
}
- (void)rightClick
{
[self goBack];
}
- (void)dealloc
{
NSLog(@"%s",__FUNCTION__);
[self.webView removeObserver:self forKeyPath:@"estimatedProgress"];
}
#pragma mark - private method
- (void)getLocation
{
//
// js
NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",@"XXXX"];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
NSString *jsStr2 = @"window.ctuapp_share_img";
[self.webView evaluateJavaScript:jsStr2 completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)shareWithParams:(NSDictionary *)tempDic
{
if (![tempDic isKindOfClass:[NSDictionary class]]) {
return;
}
NSString *title = [tempDic objectForKey:@"title"];
NSString *content = [tempDic objectForKey:@"content"];
NSString *url = [tempDic objectForKey:@"url"];
//
// js
NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@','%@','%@')",title,content,url];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)changeBGColor:(NSArray *)params
{
if (![params isKindOfClass:[NSArray class]]) {
return;
}
if (params.count < 4) {
return;
}
CGFloat r = [params[0] floatValue];
CGFloat g = [params[1] floatValue];
CGFloat b = [params[2] floatValue];
CGFloat a = [params[3] floatValue];
self.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}
- (void)payWithParams:(NSDictionary *)tempDic
{
if (![tempDic isKindOfClass:[NSDictionary class]]) {
return;
}
NSString *orderNo = [tempDic objectForKey:@"order_no"];
long long amount = [[tempDic objectForKey:@"amount"] longLongValue];
NSString *subject = [tempDic objectForKey:@"subject"];
NSString *channel = [tempDic objectForKey:@"channel"];
NSLog(@"%@---%lld---%@---%@",orderNo,amount,subject,channel);
//
// js
NSString *jsStr = [NSString stringWithFormat:@"payResult('%@')",@""];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
}
- (void)shakeAction
{
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
[HLAudioPlayer playMusic:@"shake_sound_male.wav"];
}
- (void)goBack
{
[self.webView goBack];
}
- (void)playSound:(NSString *)fileName
{
if (![fileName isKindOfClass:[NSString class]]) {
return;
}
[HLAudioPlayer playMusic:fileName];
}
#pragma mark - KVO
// wkWebView
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == self.webView && [keyPath isEqualToString:@"estimatedProgress"]) {
CGFloat newprogress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue];
if (newprogress == 1) {
[self.progressView setProgress:1.0 animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.progressView.hidden = YES;
[self.progressView setProgress:0 animated:NO];
});
}else {
self.progressView.hidden = NO;
[self.progressView setProgress:newprogress animated:YES];
}
}
}
#pragma mark - WKUIDelegate
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
completionHandler();
}]];
[self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - WKScriptMessageHandler
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
{
// message.body -- Allowed types are NSNumber, NSString, NSDate, NSArray,NSDictionary, and NSNull.
NSLog(@"body:%@",message.body);
if ([message.name isEqualToString:@"ScanAction"]) {
NSLog(@"");
} else if ([message.name isEqualToString:@"Location"]) {
[self getLocation];
} else if ([message.name isEqualToString:@"Share"]) {
[self shareWithParams:message.body];
} else if ([message.name isEqualToString:@"Color"]) {
[self changeBGColor:message.body];
} else if ([message.name isEqualToString:@"Pay"]) {
[self payWithParams:message.body];
} else if ([message.name isEqualToString:@"Shake"]) {
[self shakeAction];
} else if ([message.name isEqualToString:@"GoBack"]) {
[self goBack];
} else if ([message.name isEqualToString:@"PlaySound"]) {
[self playSound:message.body];
}
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_MessageHandler/JS_MessageHandlerViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 2,088 |
```objective-c
//
// HLAudioPlayer.m
//
//
// Created by Harvey on 14/6/2.
//
#import "HLAudioPlayer.h"
@implementation HLAudioPlayer
+ (void)initialize
{
//
AVAudioSession *session = [AVAudioSession sharedInstance];
//
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
//
[session setActive:YES error:nil];
}
// Id
static NSMutableDictionary *_soundIDs;
+ (NSMutableDictionary *)soundIDs
{
if (!_soundIDs) {
_soundIDs = [NSMutableDictionary dictionary];
}
return _soundIDs;
}
//
static NSMutableDictionary *_musicPlayers;
+ (NSMutableDictionary *)musicPlayers
{
if (!_musicPlayers) {
_musicPlayers = [NSMutableDictionary dictionary];
}
return _musicPlayers;
}
+ (AVAudioPlayer *)playMusic:(NSString *)fileName
{
if (!fileName) {
return nil;
}
AVAudioPlayer *player = [self musicPlayers][fileName];
if (!player) {
NSURL *URL = [[NSBundle mainBundle] URLForResource:fileName withExtension:nil];
if (!URL) {
return nil;
}
player = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:nil];
if (![player prepareToPlay]) {
return nil;
}
[self musicPlayers][fileName] = player;
}
if (!player.isPlaying) {
[player play];
}
return player;
}
+ (void)pauseMusic:(NSString *)fileName
{
if (!fileName) {
return;
}
AVAudioPlayer *player = [self musicPlayers][fileName];
[player pause];
}
+ (void)stopMusic:(NSString *)fileName
{
if (!fileName) {
return;
}
AVAudioPlayer *player = [self musicPlayers][fileName];
[player stop];
[[self musicPlayers] removeObjectForKey:fileName];
}
+ (void)playSound:(NSString *)soundName
{
if (!soundName) {
return;
}
SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
if (!soundID) {
NSURL *URL = [[NSBundle mainBundle] URLForResource:soundName withExtension:nil];
if (!URL) {
return;
}
AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(URL), &soundID);
[self soundIDs][soundName] = @(soundID);
}
AudioServicesPlaySystemSound(soundID);
}
+ (void)disposeSound:(NSString *)soundName
{
if (!soundName) {
return;
}
SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
if (soundID) {
AudioServicesDisposeSystemSoundID(soundID);
[[self soundIDs] removeObjectForKey:soundName];
}
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_MessageHandler/HLAudioPlayer.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 632 |
```objective-c
/**
* Macros for metaprogramming
* ExtendedC
*
* Released under the MIT license
*/
#ifndef EXTC_METAMACROS_H
#define EXTC_METAMACROS_H
/**
* Executes one or more expressions (which may have a void type, such as a call
* to a function that returns no value) and always returns true.
*/
#define metamacro_exprify(...) \
((__VA_ARGS__), true)
/**
* Returns a string representation of VALUE after full macro expansion.
*/
#define metamacro_stringify(VALUE) \
metamacro_stringify_(VALUE)
/**
* Returns A and B concatenated after full macro expansion.
*/
#define metamacro_concat(A, B) \
metamacro_concat_(A, B)
/**
* Returns the Nth variadic argument (starting from zero). At least
* N + 1 variadic arguments must be given. N must be between zero and twenty,
* inclusive.
*/
#define metamacro_at(N, ...) \
metamacro_concat(metamacro_at, N)(__VA_ARGS__)
/**
* Returns the number of arguments (up to twenty) provided to the macro. At
* least one argument must be provided.
*
* Inspired by P99: path_to_url
*/
#define metamacro_argcount(...) \
metamacro_at(20, __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
/**
* Identical to #metamacro_foreach_cxt, except that no CONTEXT argument is
* given. Only the index and current argument will thus be passed to MACRO.
*/
#define metamacro_foreach(MACRO, SEP, ...) \
metamacro_foreach_cxt(metamacro_foreach_iter, SEP, MACRO, __VA_ARGS__)
/**
* For each consecutive variadic argument (up to twenty), MACRO is passed the
* zero-based index of the current argument, CONTEXT, and then the argument
* itself. The results of adjoining invocations of MACRO are then separated by
* SEP.
*
* Inspired by P99: path_to_url
*/
#define metamacro_foreach_cxt(MACRO, SEP, CONTEXT, ...) \
metamacro_concat(metamacro_foreach_cxt, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__)
/**
* Identical to #metamacro_foreach_cxt. This can be used when the former would
* fail due to recursive macro expansion.
*/
#define metamacro_foreach_cxt_recursive(MACRO, SEP, CONTEXT, ...) \
metamacro_concat(metamacro_foreach_cxt_recursive, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__)
/**
* In consecutive order, appends each variadic argument (up to twenty) onto
* BASE. The resulting concatenations are then separated by SEP.
*
* This is primarily useful to manipulate a list of macro invocations into instead
* invoking a different, possibly related macro.
*/
#define metamacro_foreach_concat(BASE, SEP, ...) \
metamacro_foreach_cxt(metamacro_foreach_concat_iter, SEP, BASE, __VA_ARGS__)
/**
* Iterates COUNT times, each time invoking MACRO with the current index
* (starting at zero) and CONTEXT. The results of adjoining invocations of MACRO
* are then separated by SEP.
*
* COUNT must be an integer between zero and twenty, inclusive.
*/
#define metamacro_for_cxt(COUNT, MACRO, SEP, CONTEXT) \
metamacro_concat(metamacro_for_cxt, COUNT)(MACRO, SEP, CONTEXT)
/**
* Returns the first argument given. At least one argument must be provided.
*
* This is useful when implementing a variadic macro, where you may have only
* one variadic argument, but no way to retrieve it (for example, because \c ...
* always needs to match at least one argument).
*
* @code
#define varmacro(...) \
metamacro_head(__VA_ARGS__)
* @endcode
*/
#define metamacro_head(...) \
metamacro_head_(__VA_ARGS__, 0)
/**
* Returns every argument except the first. At least two arguments must be
* provided.
*/
#define metamacro_tail(...) \
metamacro_tail_(__VA_ARGS__)
/**
* Returns the first N (up to twenty) variadic arguments as a new argument list.
* At least N variadic arguments must be provided.
*/
#define metamacro_take(N, ...) \
metamacro_concat(metamacro_take, N)(__VA_ARGS__)
/**
* Removes the first N (up to twenty) variadic arguments from the given argument
* list. At least N variadic arguments must be provided.
*/
#define metamacro_drop(N, ...) \
metamacro_concat(metamacro_drop, N)(__VA_ARGS__)
/**
* Decrements VAL, which must be a number between zero and twenty, inclusive.
*
* This is primarily useful when dealing with indexes and counts in
* metaprogramming.
*/
#define metamacro_dec(VAL) \
metamacro_at(VAL, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
/**
* Increments VAL, which must be a number between zero and twenty, inclusive.
*
* This is primarily useful when dealing with indexes and counts in
* metaprogramming.
*/
#define metamacro_inc(VAL) \
metamacro_at(VAL, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
/**
* If A is equal to B, the next argument list is expanded; otherwise, the
* argument list after that is expanded. A and B must be numbers between zero
* and twenty, inclusive. Additionally, B must be greater than or equal to A.
*
* @code
// expands to true
metamacro_if_eq(0, 0)(true)(false)
// expands to false
metamacro_if_eq(0, 1)(true)(false)
* @endcode
*
* This is primarily useful when dealing with indexes and counts in
* metaprogramming.
*/
#define metamacro_if_eq(A, B) \
metamacro_concat(metamacro_if_eq, A)(B)
/**
* Identical to #metamacro_if_eq. This can be used when the former would fail
* due to recursive macro expansion.
*/
#define metamacro_if_eq_recursive(A, B) \
metamacro_concat(metamacro_if_eq_recursive, A)(B)
/**
* Returns 1 if N is an even number, or 0 otherwise. N must be between zero and
* twenty, inclusive.
*
* For the purposes of this test, zero is considered even.
*/
#define metamacro_is_even(N) \
metamacro_at(N, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
/**
* Returns the logical NOT of B, which must be the number zero or one.
*/
#define metamacro_not(B) \
metamacro_at(B, 1, 0)
// IMPLEMENTATION DETAILS FOLLOW!
// Do not write code that depends on anything below this line.
#define metamacro_stringify_(VALUE) # VALUE
#define metamacro_concat_(A, B) A ## B
#define metamacro_foreach_iter(INDEX, MACRO, ARG) MACRO(INDEX, ARG)
#define metamacro_head_(FIRST, ...) FIRST
#define metamacro_tail_(FIRST, ...) __VA_ARGS__
#define metamacro_consume_(...)
#define metamacro_expand_(...) __VA_ARGS__
// implemented from scratch so that metamacro_concat() doesn't end up nesting
#define metamacro_foreach_concat_iter(INDEX, BASE, ARG) metamacro_foreach_concat_iter_(BASE, ARG)
#define metamacro_foreach_concat_iter_(BASE, ARG) BASE ## ARG
// metamacro_at expansions
#define metamacro_at0(...) metamacro_head(__VA_ARGS__)
#define metamacro_at1(_0, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at2(_0, _1, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at3(_0, _1, _2, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at4(_0, _1, _2, _3, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at5(_0, _1, _2, _3, _4, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at6(_0, _1, _2, _3, _4, _5, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at7(_0, _1, _2, _3, _4, _5, _6, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at8(_0, _1, _2, _3, _4, _5, _6, _7, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at9(_0, _1, _2, _3, _4, _5, _6, _7, _8, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at13(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at14(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at15(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at17(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at18(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at19(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, ...) metamacro_head(__VA_ARGS__)
#define metamacro_at20(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, ...) metamacro_head(__VA_ARGS__)
// metamacro_foreach_cxt expansions
#define metamacro_foreach_cxt0(MACRO, SEP, CONTEXT)
#define metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0)
#define metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \
metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) \
SEP \
MACRO(1, CONTEXT, _1)
#define metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \
metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \
SEP \
MACRO(2, CONTEXT, _2)
#define metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \
SEP \
MACRO(3, CONTEXT, _3)
#define metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
SEP \
MACRO(4, CONTEXT, _4)
#define metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
SEP \
MACRO(5, CONTEXT, _5)
#define metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
SEP \
MACRO(6, CONTEXT, _6)
#define metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
SEP \
MACRO(7, CONTEXT, _7)
#define metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
SEP \
MACRO(8, CONTEXT, _8)
#define metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
SEP \
MACRO(9, CONTEXT, _9)
#define metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
SEP \
MACRO(10, CONTEXT, _10)
#define metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
SEP \
MACRO(11, CONTEXT, _11)
#define metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
SEP \
MACRO(12, CONTEXT, _12)
#define metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
SEP \
MACRO(13, CONTEXT, _13)
#define metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
SEP \
MACRO(14, CONTEXT, _14)
#define metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
SEP \
MACRO(15, CONTEXT, _15)
#define metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
SEP \
MACRO(16, CONTEXT, _16)
#define metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
SEP \
MACRO(17, CONTEXT, _17)
#define metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
SEP \
MACRO(18, CONTEXT, _18)
#define metamacro_foreach_cxt20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \
metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
SEP \
MACRO(19, CONTEXT, _19)
// metamacro_foreach_cxt_recursive expansions
#define metamacro_foreach_cxt_recursive0(MACRO, SEP, CONTEXT)
#define metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0)
#define metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \
metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) \
SEP \
MACRO(1, CONTEXT, _1)
#define metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \
metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \
SEP \
MACRO(2, CONTEXT, _2)
#define metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \
SEP \
MACRO(3, CONTEXT, _3)
#define metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \
SEP \
MACRO(4, CONTEXT, _4)
#define metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \
SEP \
MACRO(5, CONTEXT, _5)
#define metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \
SEP \
MACRO(6, CONTEXT, _6)
#define metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \
SEP \
MACRO(7, CONTEXT, _7)
#define metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \
SEP \
MACRO(8, CONTEXT, _8)
#define metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \
SEP \
MACRO(9, CONTEXT, _9)
#define metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
SEP \
MACRO(10, CONTEXT, _10)
#define metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
SEP \
MACRO(11, CONTEXT, _11)
#define metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
SEP \
MACRO(12, CONTEXT, _12)
#define metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
SEP \
MACRO(13, CONTEXT, _13)
#define metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
SEP \
MACRO(14, CONTEXT, _14)
#define metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
SEP \
MACRO(15, CONTEXT, _15)
#define metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
SEP \
MACRO(16, CONTEXT, _16)
#define metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
SEP \
MACRO(17, CONTEXT, _17)
#define metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
SEP \
MACRO(18, CONTEXT, _18)
#define metamacro_foreach_cxt_recursive20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \
metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \
SEP \
MACRO(19, CONTEXT, _19)
// metamacro_for_cxt expansions
#define metamacro_for_cxt0(MACRO, SEP, CONTEXT)
#define metamacro_for_cxt1(MACRO, SEP, CONTEXT) MACRO(0, CONTEXT)
#define metamacro_for_cxt2(MACRO, SEP, CONTEXT) \
metamacro_for_cxt1(MACRO, SEP, CONTEXT) \
SEP \
MACRO(1, CONTEXT)
#define metamacro_for_cxt3(MACRO, SEP, CONTEXT) \
metamacro_for_cxt2(MACRO, SEP, CONTEXT) \
SEP \
MACRO(2, CONTEXT)
#define metamacro_for_cxt4(MACRO, SEP, CONTEXT) \
metamacro_for_cxt3(MACRO, SEP, CONTEXT) \
SEP \
MACRO(3, CONTEXT)
#define metamacro_for_cxt5(MACRO, SEP, CONTEXT) \
metamacro_for_cxt4(MACRO, SEP, CONTEXT) \
SEP \
MACRO(4, CONTEXT)
#define metamacro_for_cxt6(MACRO, SEP, CONTEXT) \
metamacro_for_cxt5(MACRO, SEP, CONTEXT) \
SEP \
MACRO(5, CONTEXT)
#define metamacro_for_cxt7(MACRO, SEP, CONTEXT) \
metamacro_for_cxt6(MACRO, SEP, CONTEXT) \
SEP \
MACRO(6, CONTEXT)
#define metamacro_for_cxt8(MACRO, SEP, CONTEXT) \
metamacro_for_cxt7(MACRO, SEP, CONTEXT) \
SEP \
MACRO(7, CONTEXT)
#define metamacro_for_cxt9(MACRO, SEP, CONTEXT) \
metamacro_for_cxt8(MACRO, SEP, CONTEXT) \
SEP \
MACRO(8, CONTEXT)
#define metamacro_for_cxt10(MACRO, SEP, CONTEXT) \
metamacro_for_cxt9(MACRO, SEP, CONTEXT) \
SEP \
MACRO(9, CONTEXT)
#define metamacro_for_cxt11(MACRO, SEP, CONTEXT) \
metamacro_for_cxt10(MACRO, SEP, CONTEXT) \
SEP \
MACRO(10, CONTEXT)
#define metamacro_for_cxt12(MACRO, SEP, CONTEXT) \
metamacro_for_cxt11(MACRO, SEP, CONTEXT) \
SEP \
MACRO(11, CONTEXT)
#define metamacro_for_cxt13(MACRO, SEP, CONTEXT) \
metamacro_for_cxt12(MACRO, SEP, CONTEXT) \
SEP \
MACRO(12, CONTEXT)
#define metamacro_for_cxt14(MACRO, SEP, CONTEXT) \
metamacro_for_cxt13(MACRO, SEP, CONTEXT) \
SEP \
MACRO(13, CONTEXT)
#define metamacro_for_cxt15(MACRO, SEP, CONTEXT) \
metamacro_for_cxt14(MACRO, SEP, CONTEXT) \
SEP \
MACRO(14, CONTEXT)
#define metamacro_for_cxt16(MACRO, SEP, CONTEXT) \
metamacro_for_cxt15(MACRO, SEP, CONTEXT) \
SEP \
MACRO(15, CONTEXT)
#define metamacro_for_cxt17(MACRO, SEP, CONTEXT) \
metamacro_for_cxt16(MACRO, SEP, CONTEXT) \
SEP \
MACRO(16, CONTEXT)
#define metamacro_for_cxt18(MACRO, SEP, CONTEXT) \
metamacro_for_cxt17(MACRO, SEP, CONTEXT) \
SEP \
MACRO(17, CONTEXT)
#define metamacro_for_cxt19(MACRO, SEP, CONTEXT) \
metamacro_for_cxt18(MACRO, SEP, CONTEXT) \
SEP \
MACRO(18, CONTEXT)
#define metamacro_for_cxt20(MACRO, SEP, CONTEXT) \
metamacro_for_cxt19(MACRO, SEP, CONTEXT) \
SEP \
MACRO(19, CONTEXT)
// metamacro_if_eq expansions
#define metamacro_if_eq0(VALUE) \
metamacro_concat(metamacro_if_eq0_, VALUE)
#define metamacro_if_eq0_0(...) __VA_ARGS__ metamacro_consume_
#define metamacro_if_eq0_1(...) metamacro_expand_
#define metamacro_if_eq0_2(...) metamacro_expand_
#define metamacro_if_eq0_3(...) metamacro_expand_
#define metamacro_if_eq0_4(...) metamacro_expand_
#define metamacro_if_eq0_5(...) metamacro_expand_
#define metamacro_if_eq0_6(...) metamacro_expand_
#define metamacro_if_eq0_7(...) metamacro_expand_
#define metamacro_if_eq0_8(...) metamacro_expand_
#define metamacro_if_eq0_9(...) metamacro_expand_
#define metamacro_if_eq0_10(...) metamacro_expand_
#define metamacro_if_eq0_11(...) metamacro_expand_
#define metamacro_if_eq0_12(...) metamacro_expand_
#define metamacro_if_eq0_13(...) metamacro_expand_
#define metamacro_if_eq0_14(...) metamacro_expand_
#define metamacro_if_eq0_15(...) metamacro_expand_
#define metamacro_if_eq0_16(...) metamacro_expand_
#define metamacro_if_eq0_17(...) metamacro_expand_
#define metamacro_if_eq0_18(...) metamacro_expand_
#define metamacro_if_eq0_19(...) metamacro_expand_
#define metamacro_if_eq0_20(...) metamacro_expand_
#define metamacro_if_eq1(VALUE) metamacro_if_eq0(metamacro_dec(VALUE))
#define metamacro_if_eq2(VALUE) metamacro_if_eq1(metamacro_dec(VALUE))
#define metamacro_if_eq3(VALUE) metamacro_if_eq2(metamacro_dec(VALUE))
#define metamacro_if_eq4(VALUE) metamacro_if_eq3(metamacro_dec(VALUE))
#define metamacro_if_eq5(VALUE) metamacro_if_eq4(metamacro_dec(VALUE))
#define metamacro_if_eq6(VALUE) metamacro_if_eq5(metamacro_dec(VALUE))
#define metamacro_if_eq7(VALUE) metamacro_if_eq6(metamacro_dec(VALUE))
#define metamacro_if_eq8(VALUE) metamacro_if_eq7(metamacro_dec(VALUE))
#define metamacro_if_eq9(VALUE) metamacro_if_eq8(metamacro_dec(VALUE))
#define metamacro_if_eq10(VALUE) metamacro_if_eq9(metamacro_dec(VALUE))
#define metamacro_if_eq11(VALUE) metamacro_if_eq10(metamacro_dec(VALUE))
#define metamacro_if_eq12(VALUE) metamacro_if_eq11(metamacro_dec(VALUE))
#define metamacro_if_eq13(VALUE) metamacro_if_eq12(metamacro_dec(VALUE))
#define metamacro_if_eq14(VALUE) metamacro_if_eq13(metamacro_dec(VALUE))
#define metamacro_if_eq15(VALUE) metamacro_if_eq14(metamacro_dec(VALUE))
#define metamacro_if_eq16(VALUE) metamacro_if_eq15(metamacro_dec(VALUE))
#define metamacro_if_eq17(VALUE) metamacro_if_eq16(metamacro_dec(VALUE))
#define metamacro_if_eq18(VALUE) metamacro_if_eq17(metamacro_dec(VALUE))
#define metamacro_if_eq19(VALUE) metamacro_if_eq18(metamacro_dec(VALUE))
#define metamacro_if_eq20(VALUE) metamacro_if_eq19(metamacro_dec(VALUE))
// metamacro_if_eq_recursive expansions
#define metamacro_if_eq_recursive0(VALUE) \
metamacro_concat(metamacro_if_eq_recursive0_, VALUE)
#define metamacro_if_eq_recursive0_0(...) __VA_ARGS__ metamacro_consume_
#define metamacro_if_eq_recursive0_1(...) metamacro_expand_
#define metamacro_if_eq_recursive0_2(...) metamacro_expand_
#define metamacro_if_eq_recursive0_3(...) metamacro_expand_
#define metamacro_if_eq_recursive0_4(...) metamacro_expand_
#define metamacro_if_eq_recursive0_5(...) metamacro_expand_
#define metamacro_if_eq_recursive0_6(...) metamacro_expand_
#define metamacro_if_eq_recursive0_7(...) metamacro_expand_
#define metamacro_if_eq_recursive0_8(...) metamacro_expand_
#define metamacro_if_eq_recursive0_9(...) metamacro_expand_
#define metamacro_if_eq_recursive0_10(...) metamacro_expand_
#define metamacro_if_eq_recursive0_11(...) metamacro_expand_
#define metamacro_if_eq_recursive0_12(...) metamacro_expand_
#define metamacro_if_eq_recursive0_13(...) metamacro_expand_
#define metamacro_if_eq_recursive0_14(...) metamacro_expand_
#define metamacro_if_eq_recursive0_15(...) metamacro_expand_
#define metamacro_if_eq_recursive0_16(...) metamacro_expand_
#define metamacro_if_eq_recursive0_17(...) metamacro_expand_
#define metamacro_if_eq_recursive0_18(...) metamacro_expand_
#define metamacro_if_eq_recursive0_19(...) metamacro_expand_
#define metamacro_if_eq_recursive0_20(...) metamacro_expand_
#define metamacro_if_eq_recursive1(VALUE) metamacro_if_eq_recursive0(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive2(VALUE) metamacro_if_eq_recursive1(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive3(VALUE) metamacro_if_eq_recursive2(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive4(VALUE) metamacro_if_eq_recursive3(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive5(VALUE) metamacro_if_eq_recursive4(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive6(VALUE) metamacro_if_eq_recursive5(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive7(VALUE) metamacro_if_eq_recursive6(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive8(VALUE) metamacro_if_eq_recursive7(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive9(VALUE) metamacro_if_eq_recursive8(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive10(VALUE) metamacro_if_eq_recursive9(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive11(VALUE) metamacro_if_eq_recursive10(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive12(VALUE) metamacro_if_eq_recursive11(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive13(VALUE) metamacro_if_eq_recursive12(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive14(VALUE) metamacro_if_eq_recursive13(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive15(VALUE) metamacro_if_eq_recursive14(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive16(VALUE) metamacro_if_eq_recursive15(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive17(VALUE) metamacro_if_eq_recursive16(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive18(VALUE) metamacro_if_eq_recursive17(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive19(VALUE) metamacro_if_eq_recursive18(metamacro_dec(VALUE))
#define metamacro_if_eq_recursive20(VALUE) metamacro_if_eq_recursive19(metamacro_dec(VALUE))
// metamacro_take expansions
#define metamacro_take0(...)
#define metamacro_take1(...) metamacro_head(__VA_ARGS__)
#define metamacro_take2(...) metamacro_head(__VA_ARGS__), metamacro_take1(metamacro_tail(__VA_ARGS__))
#define metamacro_take3(...) metamacro_head(__VA_ARGS__), metamacro_take2(metamacro_tail(__VA_ARGS__))
#define metamacro_take4(...) metamacro_head(__VA_ARGS__), metamacro_take3(metamacro_tail(__VA_ARGS__))
#define metamacro_take5(...) metamacro_head(__VA_ARGS__), metamacro_take4(metamacro_tail(__VA_ARGS__))
#define metamacro_take6(...) metamacro_head(__VA_ARGS__), metamacro_take5(metamacro_tail(__VA_ARGS__))
#define metamacro_take7(...) metamacro_head(__VA_ARGS__), metamacro_take6(metamacro_tail(__VA_ARGS__))
#define metamacro_take8(...) metamacro_head(__VA_ARGS__), metamacro_take7(metamacro_tail(__VA_ARGS__))
#define metamacro_take9(...) metamacro_head(__VA_ARGS__), metamacro_take8(metamacro_tail(__VA_ARGS__))
#define metamacro_take10(...) metamacro_head(__VA_ARGS__), metamacro_take9(metamacro_tail(__VA_ARGS__))
#define metamacro_take11(...) metamacro_head(__VA_ARGS__), metamacro_take10(metamacro_tail(__VA_ARGS__))
#define metamacro_take12(...) metamacro_head(__VA_ARGS__), metamacro_take11(metamacro_tail(__VA_ARGS__))
#define metamacro_take13(...) metamacro_head(__VA_ARGS__), metamacro_take12(metamacro_tail(__VA_ARGS__))
#define metamacro_take14(...) metamacro_head(__VA_ARGS__), metamacro_take13(metamacro_tail(__VA_ARGS__))
#define metamacro_take15(...) metamacro_head(__VA_ARGS__), metamacro_take14(metamacro_tail(__VA_ARGS__))
#define metamacro_take16(...) metamacro_head(__VA_ARGS__), metamacro_take15(metamacro_tail(__VA_ARGS__))
#define metamacro_take17(...) metamacro_head(__VA_ARGS__), metamacro_take16(metamacro_tail(__VA_ARGS__))
#define metamacro_take18(...) metamacro_head(__VA_ARGS__), metamacro_take17(metamacro_tail(__VA_ARGS__))
#define metamacro_take19(...) metamacro_head(__VA_ARGS__), metamacro_take18(metamacro_tail(__VA_ARGS__))
#define metamacro_take20(...) metamacro_head(__VA_ARGS__), metamacro_take19(metamacro_tail(__VA_ARGS__))
// metamacro_drop expansions
#define metamacro_drop0(...) __VA_ARGS__
#define metamacro_drop1(...) metamacro_tail(__VA_ARGS__)
#define metamacro_drop2(...) metamacro_drop1(metamacro_tail(__VA_ARGS__))
#define metamacro_drop3(...) metamacro_drop2(metamacro_tail(__VA_ARGS__))
#define metamacro_drop4(...) metamacro_drop3(metamacro_tail(__VA_ARGS__))
#define metamacro_drop5(...) metamacro_drop4(metamacro_tail(__VA_ARGS__))
#define metamacro_drop6(...) metamacro_drop5(metamacro_tail(__VA_ARGS__))
#define metamacro_drop7(...) metamacro_drop6(metamacro_tail(__VA_ARGS__))
#define metamacro_drop8(...) metamacro_drop7(metamacro_tail(__VA_ARGS__))
#define metamacro_drop9(...) metamacro_drop8(metamacro_tail(__VA_ARGS__))
#define metamacro_drop10(...) metamacro_drop9(metamacro_tail(__VA_ARGS__))
#define metamacro_drop11(...) metamacro_drop10(metamacro_tail(__VA_ARGS__))
#define metamacro_drop12(...) metamacro_drop11(metamacro_tail(__VA_ARGS__))
#define metamacro_drop13(...) metamacro_drop12(metamacro_tail(__VA_ARGS__))
#define metamacro_drop14(...) metamacro_drop13(metamacro_tail(__VA_ARGS__))
#define metamacro_drop15(...) metamacro_drop14(metamacro_tail(__VA_ARGS__))
#define metamacro_drop16(...) metamacro_drop15(metamacro_tail(__VA_ARGS__))
#define metamacro_drop17(...) metamacro_drop16(metamacro_tail(__VA_ARGS__))
#define metamacro_drop18(...) metamacro_drop17(metamacro_tail(__VA_ARGS__))
#define metamacro_drop19(...) metamacro_drop18(metamacro_tail(__VA_ARGS__))
#define metamacro_drop20(...) metamacro_drop19(metamacro_tail(__VA_ARGS__))
#endif
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/WebViewJSBridge/extobjc/metamacros.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 10,834 |
```html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script language="javascript">
var ctuapp_share_img="www.baidu.com";
// null
function scanClick() {
window.webkit.messageHandlers.ScanAction.postMessage(null);
}
//
function shareClick() {
window.webkit.messageHandlers.Share.postMessage({title:'',content:'',url:'path_to_url});
}
function locationClick() {
window.webkit.messageHandlers.Location.postMessage(null);
}
function setLocation(location) {
asyncAlert(location);
document.getElementById("returnValue").value = location;
}
function getQRCode(result) {
asyncAlert(result);
document.getElementById("returnValue").value = result;
}
//
function colorClick() {
window.webkit.messageHandlers.Color.postMessage([67,205,128,0.5]);
}
function payClick() {
window.webkit.messageHandlers.Pay.postMessage({order_no:'201511120981234',channel:'wx',amount:1,subject:''});
}
function payResult(str) {
asyncAlert(str);
document.getElementById("returnValue").value = str;
}
function shareResult(channel_id,share_channel,share_url) {
var content = channel_id+","+share_channel+","+share_url;
asyncAlert(content);
document.getElementById("returnValue").value = content;
}
function shake() {
window.webkit.messageHandlers.Shake.postMessage(null);
}
function goBack() {
window.webkit.messageHandlers.GoBack.postMessage(null);
}
//
function playSound() {
window.webkit.messageHandlers.PlaySound.postMessage('shake_sound_male.wav');
}
function asyncAlert(content) {
setTimeout(function(){
alert(content);
},1);
}
</script>
</head>
<body>
<h1></h1>
<input type="button" value="" onclick="scanClick()" />
<input type="button" value="" onclick="locationClick()" />
<input type="button" value="" onclick="colorClick()" />
<input type="button" value="" onclick="shareClick()" />
<input type="button" value="" onclick="payClick()" />
<input type="button" value="" onclick="shake()" />
<input type="button" value="" onclick="goBack()" />
<input type="button" value="" onclick="playSound()" />
<h1></h1>
<input type="file" />
<h1></h1>
<textarea id ="returnValue" type="value" rows="5" cols="40">
</textarea>
<h4></h4>
<table border="1" style="width:90%;height:600px">
<tr>
<th></th>
<td>Bill Gates</td>
</tr>
<tr>
<th></th>
<td>555 77 854</td>
</tr>
<tr>
<th></th>
<td>555 77 855</td>
</tr>
</table>
</body>
</html>
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_MessageHandler/JS_MessageHandler.html | html | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 688 |
```objective-c
//
// Author_KVC.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
@interface Author_KVC : NSObject{
NSString *_name;
//,
NSArray *_issueBook;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Author_KVC.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 62 |
```objective-c
//
// HLAudioPlayer.h
//
//
// Created by Harvey on 14/6/2.
//
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@interface HLAudioPlayer : NSObject
+ (AVAudioPlayer *)playMusic:(NSString *)fileName;
+ (void)pauseMusic:(NSString *)fileName;
+ (void)stopMusic:(NSString *)fileName;
+ (void)playSound:(NSString *)soundName;
+ (void)disposeSound:(NSString *)soundName;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/JS/JS_MessageHandler/HLAudioPlayer.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 109 |
```objective-c
//
// Author_KVC.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Author_KVC.h"
@implementation Author_KVC
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Author_KVC.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 45 |
```objective-c
//
// Person_KVC.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
#import "Dog_KVC.h"
@interface Person_KVC : NSObject{
@private
NSString *_name;
NSInteger *age;
Dog_KVC *_dog;
/*
Personget/setdescription
*/
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Person_KVC.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 88 |
```objective-c
//
// Nure_KVO.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Nure_KVO.h"
#import "Children_KVO.h"
@implementation Nure_KVO
- (id) initWithChildren:(Children_KVO *)children{
self = [super init];
if(self != nil){
_children = children;
//hapyValue
//KVO_childrenhapyValue
[_children addObserver:self forKeyPath:@"happyValue" options:NSKeyValueObservingOptionNew |NSKeyValueObservingOptionOld context:@"context"];
//hurryValue
[_children addObserver:self forKeyPath:@"hurryValue" options:NSKeyValueObservingOptionNew |NSKeyValueObservingOptionOld context:@"context"];
}
return self;
}
//
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
NSLog(@"%@",change);
//changekey
//keyPath
if([keyPath isEqualToString:@"happyValue"]){
//changeoldnewaddObserver
//NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
//[change objectForKey:@"old"]
NSNumber *hapyValue = [change objectForKey:@"new"];//
NSInteger *value = [hapyValue integerValue];
if(value < 95){
//do something...
NSLog(@"baby is crying");
}
}else if([keyPath isEqualToString:@"hurryValue"]){
//changeoldnewaddObserver
//NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
//[change objectForKey:@"old"]
NSNumber *hurryValue = [change objectForKey:@"new"];//
NSInteger *value = [hurryValue integerValue];
if(value < 95){
NSLog(@"baby is hungry");
}
}
NSLog(@"%@",context);//addObservercontext
//KVC
}
// ,
- (void)dealloc{
//
[_children removeObserver:self forKeyPath:@"happyValue"];
[_children removeObserver:self forKeyPath:@"hurryValue"];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Nure_KVO.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 453 |
```objective-c
//
// KVCViewController.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <UIKit/UIKit.h>
@interface KVCViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/KVCViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 46 |
```objective-c
//
// Book_KVC.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
#import "Author_KVC.h"
@interface Book_KVC : NSObject{
Author_KVC *_author;
}
@property NSString *name;
@property float price;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Book_KVC.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 71 |
```objective-c
//
// Children_KVO.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Children_KVO.h"
@implementation Children_KVO
- (id) init{
self = [super init];
if(self != nil){
//
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
self.happyValue = 100;
self.hurryValue = 100;
}
return self;
}
- (void)timerAction:(NSTimer *)timer{
//setKVO
[self setHappyValue:--_happyValue];
[self setHurryValue:--_hurryValue];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Children_KVO.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 160 |
```objective-c
//
// Book_KVC.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Book_KVC.h"
@implementation Book_KVC
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Book_KVC.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 45 |
```objective-c
//
// Person_KVC.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Person_KVC.h"
@implementation Person_KVC
- (NSString *)description{
NSLog(@"%@",_name);
return _name;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Person_KVC.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 63 |
```objective-c
//
// Dog_KVC.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
@interface Dog_KVC : NSObject
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Dog_KVC.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 46 |
```objective-c
//
// KVCViewController.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "KVCViewController.h"
#import "Person_KVC.h"
#import "Dog_KVC.h"
#import "Author_KVC.h"
#import "Book_KVC.h"
#import "Children_KVO.h"
#import "Nure_KVO.h"
@interface KVCViewController ()
@property (nonatomic, strong) Nure_KVO *nure;
@end
@implementation KVCViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
/*
:
path_to_url
*/
[self testKVC1];
[self testKVC2];
[self testKVO];
}
- (void)testKVC1 {
Person_KVC *p = [[Person_KVC alloc] init];
//
//setValuevalue,key()
[p setValue:@"bigShow" forKey:@"name"];
//
//NSNumber
//NSNumberage
[p setValue:@22 forKey:@"age"];
Dog_KVC *dog = [[Dog_KVC alloc] init];
[p setValue:dog forKey:@"dog"];
//KVCsetsetget
//
NSString *name = [p valueForKey:@"name"];
NSLog(@"%@",p);
}
- (void)testKVC2 {
//------------------KVC
/*
Book *book = [[Book alloc] init];
Author *author = [[Author alloc] init];
//
[book setValue:author forKey:@"author"];
//
//author.name,
[book setValue:@"bigShow" forKeyPath:@"author.name"];
NSString *name = [author valueForKey:@"name"];
NSLog(@"name is %@",name);
*/
//--------------------KVC
Author_KVC *author = [[Author_KVC alloc] init];
[author setValue:@"" forKeyPath:@"name"];
Book_KVC *book1 = [[Book_KVC alloc] init];
book1.name = @"";
book1.price = 9;
Book_KVC *book2 = [[Book_KVC alloc] init];
book2.name = @"";
book2.price = 10;
NSArray *array = [NSArray arrayWithObjects:book1,book2, nil];
[author setValue:array forKeyPath:@"issueBook"];
//NSNumber
//
NSArray *priceArray = [author valueForKeyPath:@"issueBook.price"];
NSLog(@"%@",priceArray);
//
NSNumber *count = [author valueForKeyPath:@"issueBook.@count"];
NSLog(@"count=%@",count);
//
NSNumber *sum = [author valueForKeyPath:@"issueBook.@sum.price"];
NSLog(@"%@",sum);
//
NSNumber *avg = [author valueForKeyPath:@"issueBook.@avg.price"];
NSLog(@"%@",avg);
//
NSNumber *max = [author valueForKeyPath:@"issueBook.@max.price"];
NSNumber *min = [author valueForKeyPath:@"issueBook.@min.price"];
}
- (void)testKVO {
Children_KVO *baby = [[Children_KVO alloc] init];
Nure_KVO *nure = [[Nure_KVO alloc] initWithChildren:baby];
self.nure = nure;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/KVCViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 693 |
```objective-c
//
// Dog_KVC.m
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import "Dog_KVC.h"
@implementation Dog_KVC
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Dog_KVC.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 45 |
```objective-c
//
// Children_KVO.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
@interface Children_KVO : NSObject
@property int happyValue;
@property int hurryValue;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Children_KVO.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 56 |
```objective-c
//
// YFStatisticalCodeViewController.m
// BigShow1949
//
// Created by apple on 16/8/25.
//
#import "YFStatisticalCodeViewController.h"
@implementation YFStatisticalCodeViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// 89634
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(10, 100, 300, 100);
label.numberOfLines = 0;
label.backgroundColor = [UIColor lightGrayColor];
label.text = @"Mac,iPhone, 9";
[self.view addSubview:label];
// :Mac,iPhone,
//
NSString *path = @"/Users/apple/GitHub/BigShow1949";
// NSString *path = @"/Users/apple/Desktop/Code/BSJZ/SJZ";
NSLog(@"%ld",codeLineCount2(path,path));
}
//
/*
url :
NSUInteger :
*/
NSUInteger codeLineCount(NSString *url) {
//1
NSFileManager *manager = [NSFileManager defaultManager];
//2
BOOL dir = NO;
//3
BOOL isExist = [manager fileExistsAtPath:url isDirectory:&dir];
//return 0
if (!isExist) {
NSLog(@"");
return 0;
}
//
//...
if (dir) {
//path
NSArray *aryPath = [manager contentsOfDirectoryAtPath:url error:nil];
//path
NSUInteger count = 0;
//
for (NSString *fileName in aryPath) {
//
NSString *fullPath = [NSString stringWithFormat:@"%@/%@",url,fileName];
//
count+=codeLineCount(fullPath);
}
return count;
}
//
else{
//,lowercaseString
NSString *extension = [[url pathExtension]lowercaseString];
if (!([extension isEqualToString:@"m" ] || [extension isEqualToString:@"h"] || [extension isEqualToString:@"h"])) {
//h/m/c
return 0;
}
//
NSString *content = [NSString stringWithContentsOfFile:url encoding:NSUTF8StringEncoding error:nil];
//
NSArray *aryFile = [content componentsSeparatedByString:@"\n"];
//
return aryFile.count;
}
return 0;
}
//
NSUInteger codeLineCount2(NSString *path,NSString *rootPath)
{
NSUInteger num = 0;
// fileYESNO
BOOL flag = NO;
//
//
NSFileManager *file = [NSFileManager defaultManager];
BOOL isExit = [file fileExistsAtPath:path isDirectory:&flag];
if(!isExit){
NSLog(@"");
return 0;
}else{
//
if(flag){
//
NSArray *a = [file contentsOfDirectoryAtPath:path error:nil];
for(id fileName in a){
//
NSString *s1 = [NSString stringWithFormat:@"%@/%@",path,fileName];
num = num + codeLineCount2(s1,rootPath);
}
}else{
// .h .m
NSString *h = @"h";
NSString *m = @"m";
NSString *c = @"c";
NSString *mm = @"mm";
NSString *swift = @"swift";
//
NSString *pathE = [[path pathExtension] lowercaseString];
NSRange rect = [path rangeOfString:rootPath];
NSString *newPath = [path stringByReplacingCharactersInRange:rect withString:@""];
if([pathE isEqualToString:h] || [pathE isEqualToString:m] || [pathE isEqualToString:c] || [pathE isEqualToString:mm]|| [pathE isEqualToString:swift]){
num = test2(path);
NSLog(@"%@ --- %ld",newPath,num);
}else{
return 0;
}
}
}
return num;
}
NSUInteger test2(NSString *path)
{
//
NSString *s1 = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
//
NSArray *a = [s1 componentsSeparatedByString:@"\n"];
return a.count;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/StatisticalCode/YFStatisticalCodeViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 915 |
```objective-c
//
// Nure_KVO.h
// BigShow1949
//
// Created by apple on 16/11/21.
//
#import <Foundation/Foundation.h>
@class Children_KVO;
@interface Nure_KVO : NSObject{
Children_KVO *_children;
}
- (id) initWithChildren:(Children_KVO *)children;
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/KVC/Nure_KVO.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 74 |
```objective-c
//
// BViewController.h
// test
//
// Created by zhht01 on 16/4/5.
//
#import <UIKit/UIKit.h>
@interface BViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/LifeCycle/BViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 43 |
```objective-c
//
// YFStatisticalCodeViewController.h
// BigShow1949
//
// Created by apple on 16/8/25.
//
#import <UIKit/UIKit.h>
@interface YFStatisticalCodeViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/StatisticalCode/YFStatisticalCodeViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// BViewController.m
// test
//
// Created by zhht01 on 16/4/5.
//
#import "BViewController.h"
@interface BViewController ()
@end
@implementation BViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"B";
self.view.backgroundColor = [UIColor whiteColor];
NSLog(@"viewDidLoad--------B");
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"viewWillAppear--------B");
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"viewDidAppear--------B");
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
NSLog(@"viewWillDisappear--------B");
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"viewDidDisappear--------B");
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/LifeCycle/BViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 187 |
```objective-c
//
// YFLifeCycleViewController.m
// BigShow1949
//
// Created by zhht01 on 16/4/7.
//
#import "YFLifeCycleViewController.h"
#import "BViewController.h"
@interface YFLifeCycleViewController ()
@end
/*
push:
2016-04-05 15:04:35.841 test[919:391291] viewDidLoad--------B
2016-04-05 15:04:35.841 test[919:391291] viewWillDisappear--------A
2016-04-05 15:04:35.842 test[919:391291] viewWillAppear--------B
2016-04-05 15:04:36.349 test[919:391291] viewDidDisappear--------A
2016-04-05 15:04:36.361 test[919:391291] viewDidAppear--------B
pop:
2016-04-05 15:12:04.681 test[926:391793] viewWillDisappear--------B
2016-04-05 15:12:04.683 test[926:391793] viewWillAppear--------A
2016-04-05 15:12:05.191 test[926:391793] viewDidDisappear--------B
2016-04-05 15:12:05.192 test[926:391793] viewDidAppear--------A
:
2016-04-05 15:07:26.236 test[926:391793] viewWillDisappear--------B
2016-04-05 15:07:26.239 test[926:391793] viewWillAppear--------A
:
2016-04-05 15:13:29.630 test[926:391793] viewWillDisappear--------B
2016-04-05 15:13:29.632 test[926:391793] viewWillAppear--------A
2016-04-05 15:13:31.664 test[926:391793] viewDidDisappear--------B
2016-04-05 15:13:31.665 test[926:391793] viewDidAppear--------A
:
2016-04-05 15:07:26.236 test[926:391793] viewWillDisappear--------B
2016-04-05 15:07:26.239 test[926:391793] viewWillAppear--------A
2016-04-05 15:07:30.357 test[926:391793] viewWillDisappear--------A
2016-04-05 15:07:30.357 test[926:391793] viewDidDisappear--------A
2016-04-05 15:07:30.360 test[926:391793] viewWillAppear--------B
2016-04-05 15:07:30.360 test[926:391793] viewDidAppear--------B
*/
@implementation YFLifeCycleViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad--------A");
self.title = @"A";
self.view.backgroundColor = [UIColor whiteColor];
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
btn.backgroundColor = [UIColor redColor];
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
- (void)btnClick:(UIButton *)button {
BViewController *bVC = [[BViewController alloc] init];
// [self presentViewController:bVC animated:YES completion:nil];
[self.navigationController pushViewController:bVC animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"viewWillAppear--------A");
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"viewDidAppear--------A");
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
NSLog(@"viewWillDisappear--------A");
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"viewDidDisappear--------A");
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/LifeCycle/YFLifeCycleViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 891 |
```objective-c
//
// YFAuthorBlogViewController.h
// appStoreDemo
//
// Created by WangMengqi on 15/9/2.
//
#import <UIKit/UIKit.h>
@interface YFAuthorBlogViewController : UITableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/AuthorBlog(作者)/YFAuthorBlogViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// YFLifeCycleViewController.h
// BigShow1949
//
// Created by zhht01 on 16/4/7.
//
#import <UIKit/UIKit.h>
@interface YFLifeCycleViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/05 - KnowledgePoint(零散知识点)/LifeCycle/YFLifeCycleViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// YFAuthorBlogViewController.m
// appStoreDemo
//
// Created by WangMengqi on 15/9/2.
//
#import "YFAuthorBlogViewController.h"
@interface YFAuthorBlogViewController ()
@property (nonatomic, strong) NSArray *dataSource;
@property (nonatomic, strong) UIWebView *webView;
@end
@implementation YFAuthorBlogViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
#pragma mark - UITableViewDataSource & UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] init];
cell.textLabel.text = self.dataSource[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
[self jumpWebViewWithUrlStr:@"path_to_url"];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 55;
}
#pragma mark - private
- (void)jumpWebViewWithUrlStr:(NSString *)urlStr {
NSURL *fileURL = [NSURL URLWithString:urlStr];
NSURLRequest *request = [NSURLRequest requestWithURL:fileURL];
[self.webView loadRequest:request];
}
#pragma mark -
- (NSArray *)dataSource {
if (!_dataSource) {
_dataSource = [NSMutableArray arrayWithObjects:@"01 - App installation failed", nil];
}
return _dataSource;
}
- (UIWebView *)webView {
if (!_webView) {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, YFScreen.width, YFScreen.height)];
_webView = webView;
[self.view addSubview:webView];
}
return _webView;
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/AuthorBlog(作者)/YFAuthorBlogViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 391 |
```objective-c
//
// YFNetworkRequestViewController.h
// BigShow1949
//
// Created by zhht01 on 16/5/17.
//
#import "BaseTableViewController.h"
@interface YFNetworkRequestViewController : BaseTableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/YFNetworkRequestViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 55 |
```objective-c
//
// YFNetworkRequestViewController.m
// BigShow1949
//
// Created by zhht01 on 16/5/17.
//
#import "YFNetworkRequestViewController.h"
@implementation YFNetworkRequestViewController
- (void)viewDidLoad {
[super viewDidLoad];
// self.titles = @[@""];
//
// self.classNames = @[@"DemoListViewController"];
[self setupDataArr:@[@[@"",@"DemoListViewController"]]];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/YFNetworkRequestViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 104 |
```objective-c
//
// DemoDetailViewController.h
// MGJRequestManagerDemo
//
// Created by limboy on 3/20/15.
//
#import <UIKit/UIKit.h>
@interface DemoDetailViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/DemoDetailViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 48 |
```objective-c
//
// DemoListViewController.h
// MGJRequestManagerDemo
//
// Created by limboy on 3/20/15.
//
#import <UIKit/UIKit.h>
typedef UIViewController *(^ViewControllerHandler)();
@interface DemoListViewController : UIViewController
+ (void)registerWithTitle:(NSString *)title handler:(ViewControllerHandler)handler;
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/DemoListViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 73 |
```objective-c
//
// MGJRequestManager.h
// MGJFoundation
//
// Created by limboy on 12/10/14.
//
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
extern NSInteger const MGJResponseCancelError;
/**
* error result object
*/
@interface MGJResponse : NSObject
@property (nonatomic) NSError *error;
@property (nonatomic) id result;
@end
@interface MGJRequestManagerConfiguration : NSObject <NSCopying>
/**
* <= 0
*/
@property (nonatomic, assign) NSInteger resultCacheDuration;
/**
* path_to_url
*/
@property (nonatomic, copy) NSString *baseURL;
/**
* AFHTTPRequestSerializer
*/
@property (nonatomic) AFHTTPRequestSerializer *requestSerializer;
/**
* AFHTTPResponseSerializer
*/
@property (nonatomic) AFHTTPResponseSerializer *responseSerializer;
/**
*
* *shouldStopProcessing YES CompletionHandler refreshToken
*/
@property (nonatomic, copy) void (^responseHandler)(AFHTTPRequestOperation *operation, id userInfo, MGJResponse *response, BOOL *shouldStopProcessing);
/**
* *shouldStopProcessing YES
*/
@property (nonatomic, copy) void (^requestHandler)(AFHTTPRequestOperation *operation, id userInfo, BOOL *shouldStopProcessing);
/**
* preRequestHandler postRequestHandler
*/
@property (nonatomic) id userInfo;
/**
*
*/
@property (nonatomic) NSDictionary *builtinParameters;
@property (nonatomic,strong) NSDictionary *builtinHeaders;
@end
typedef void (^MGJRequestManagerConfigurationHandler)(MGJRequestManagerConfiguration *configuration);
typedef void (^MGJRequestManagerCompletionHandler)(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation);
typedef void (^MGJRequestManagerParametersHandler)(NSMutableDictionary *requestParameters, NSMutableDictionary *builtinParameters);
@interface MGJRequestManager : NSObject
+ (instancetype)sharedInstance;
/**
*
*/
@property (nonatomic) AFNetworkReachabilityStatus networkStatus;
/**
* sharedInstance property configuration
* property
*/
@property(nonatomic) MGJRequestManagerConfiguration *configuration;
/**
* AFHTTPRequestOperation
*/
@property (nonatomic, readonly) NSArray *runningRequests;
/**
*
*/
@property (nonatomic, copy) MGJRequestManagerParametersHandler parametersHandler;
/**
* Operation Chain
*
* @param chainName
*/
- (void)addOperation:(AFHTTPRequestOperation *)operation toChain:(NSString *)chain;
/**
* Chain Operations
*
* @param chainName
*/
- (NSArray *)operationsInChain:(NSString *)chain;
/**
* Chain Operation
*
* @param operation
* @param chain
*/
- (void)removeOperation:(AFHTTPRequestOperation *)operation inChain:(NSString *)chain;
/**
* Chain Operations
*
* @param chain
*/
- (void)removeOperationsInChain:(NSString *)chain;
/**
* Operation
*
* @param operations operations
* @param progressBlock
* @param completionBlock
*/
- (void)batchOfRequestOperations:(NSArray *)operations
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
completionBlock:(void (^)())completionBlock;
/**
* Operation Operation startImmediately NO
*
* @param operation
*/
- (AFHTTPRequestOperation *)startOperation:(AFHTTPRequestOperation *)operation;
/**
*
*/
- (void)cancelAllRequest;
/**
* /
*
* @param method GET/POST/DELETE/PUT
* @param url url
*/
- (void)cancelHTTPOperationsWithMethod:(NSString *)method url:(NSString *)url;
/**
* Operation completionBlock
* `[operation copy]` operation
* completionBlock completionBlock
*
* @param operation Operation
*
* @return Operation
*/
- (AFHTTPRequestOperation *)reAssembleOperation:(AFHTTPRequestOperation *)operation;
- (AFHTTPRequestOperation *)GET:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
- (AFHTTPRequestOperation *)POST:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
/**
*
*/
- (AFHTTPRequestOperation *)POST:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
- (AFHTTPRequestOperation *)PUT:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
- (AFHTTPRequestOperation *)HTTPRequestOperationWithMethod:(NSString *)method
URLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler;
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/MGJRequestManager.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,198 |
```objective-c
//
// DemoDetailViewController.m
// MGJRequestManagerDemo
//
// Created by limboy on 3/20/15.
//
#import "DemoDetailViewController.h"
#import "DemoListViewController.h"
#import "MGJRequestManager.h"
#import <CommonCrypto/CommonDigest.h>
//#import <UIImageView+AFNetworking.h>
#import "UIImageView+WebCache.h"
@interface DemoDetailViewController ()
@property (nonatomic) UITextView *resultTextView;
@property (nonatomic) SEL selectedSelector;
@end
@implementation DemoDetailViewController
+ (void)load
{
DemoDetailViewController *detailViewController = [[DemoDetailViewController alloc] init];
[DemoListViewController registerWithTitle:@" GET " handler:^UIViewController *{
detailViewController.selectedSelector = @selector(makeGETRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@" POST " handler:^UIViewController *{
detailViewController.selectedSelector = @selector(makePOSTRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@" GET " handler:^UIViewController *{
detailViewController.selectedSelector = @selector(makeCacheGETRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(makeBuiltinParametersRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@" Token" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(calculateTokenEveryRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(preventFromSendingRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(handleResponse);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(handleSpecialRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(chainRequests);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(batchRequests);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(uploadImage);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(runningRequests);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@" URL " handler:^UIViewController *{
detailViewController.selectedSelector = @selector(cancelRequestByURL);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"Token" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(simulateTokenExpired);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@" Loading" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(showLoadingWhenSendingRequest);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(calculateRequestTime);
return detailViewController;
}];
[DemoListViewController registerWithTitle:@"" handler:^UIViewController *{
detailViewController.selectedSelector = @selector(addHeaderValues);
return detailViewController;
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:239.f/255 green:239.f/255 blue:244.f/255 alpha:1];
[self.view addSubview:self.resultTextView];
// Do any additional setup after loading the view.
}
- (void)appendLog:(NSString *)log
{
NSString *currentLog = self.resultTextView.text;
if (currentLog.length) {
currentLog = [currentLog stringByAppendingString:[NSString stringWithFormat:@"\n----------\n%@", log]];
} else {
currentLog = log;
}
self.resultTextView.text = currentLog;
[self.resultTextView sizeThatFits:CGSizeMake(self.view.frame.size.width, CGFLOAT_MAX)];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.resultTextView.subviews enumerateObjectsUsingBlock:^(UIImageView *obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[UIImageView class]]) {
// imageView
[obj removeFromSuperview];
}
}];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[MGJRequestManager sharedInstance].configuration = nil;
[self appendLog:@"..."];
[self.resultTextView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
[self performSelector:self.selectedSelector withObject:nil afterDelay:0];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.resultTextView removeObserver:self forKeyPath:@"contentSize"];
self.resultTextView.text = @"";
}
- (UITextView *)resultTextView
{
if (!_resultTextView) {
NSInteger padding = 20;
NSInteger viewWith = self.view.frame.size.width;
NSInteger viewHeight = self.view.frame.size.height - 64;
_resultTextView = [[UITextView alloc] initWithFrame:CGRectMake(padding, padding + 64, viewWith - padding * 2, viewHeight - padding * 2)];
_resultTextView.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:1].CGColor;
_resultTextView.layer.borderWidth = 1;
_resultTextView.editable = NO;
_resultTextView.contentInset = UIEdgeInsetsMake(-64, 0, 0, 0);
_resultTextView.font = [UIFont systemFontOfSize:14];
_resultTextView.textColor = [UIColor colorWithWhite:0.2 alpha:1];
_resultTextView.contentOffset = CGPointZero;
}
return _resultTextView;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"contentSize"]) {
NSInteger contentHeight = self.resultTextView.contentSize.height;
NSInteger textViewHeight = self.resultTextView.frame.size.height;
[self.resultTextView setContentOffset:CGPointMake(0, MAX(contentHeight - textViewHeight, 0)) animated:YES];
}
}
- (NSString *)md5String:(NSString *)string
{
const char *cStr = [string UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, (uint)strlen(cStr), result ); // This is the md5 call
return [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
}
- (void)makeGETRequest
{
[[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:@{@"foo": @"bar"} startImmediately:YES
configurationHandler:nil completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)makePOSTRequest
{
[[MGJRequestManager sharedInstance] POST:@"path_to_url" parameters:@{@"foo": @"bar"} startImmediately:YES
configurationHandler:nil completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)batchRequests
{
AFHTTPRequestOperation *operation1 = [[MGJRequestManager sharedInstance]
GET:@"path_to_url"
parameters:@{@"foo": @"bar"}
startImmediately:NO
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
AFHTTPRequestOperation *operation2 = [[MGJRequestManager sharedInstance]
GET:@"path_to_url"
parameters:@{@"foo": @"bar"}
startImmediately:NO
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
[[MGJRequestManager sharedInstance] batchOfRequestOperations:@[operation1, operation2] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
[self appendLog:[NSString stringWithFormat:@"%zd/%zd", numberOfFinishedOperations, totalNumberOfOperations]];
} completionBlock:^() {
[self appendLog:@""];
}];
}
- (void)makeCacheGETRequest
{
AFHTTPRequestOperation *operation1 = [[MGJRequestManager sharedInstance]
GET:@"path_to_url"
parameters:@{@"foo": @"bar"}
startImmediately:NO
configurationHandler:^(MGJRequestManagerConfiguration *configuration) {
configuration.resultCacheDuration = 30;
}
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:[NSString stringWithFormat:@":%@", isFromCache ? @"" : @""]];
[self appendLog:result.description];
}];
AFHTTPRequestOperation *operation2 = [[MGJRequestManager sharedInstance]
GET:@"path_to_url"
parameters:@{@"foo": @"bar"}
startImmediately:NO
configurationHandler:^(MGJRequestManagerConfiguration *configuration) {
configuration.resultCacheDuration = 30;
}
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:[NSString stringWithFormat:@":%@", isFromCache ? @"" : @""]];
[self appendLog:result.description];
}];
[[MGJRequestManager sharedInstance] addOperation:operation1 toChain:@"cache"];
[[MGJRequestManager sharedInstance] addOperation:operation2 toChain:@"cache"];
}
- (void)makeBuiltinParametersRequest
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.builtinParameters = @{@"t": [NSString stringWithFormat:@"%lf", [[NSDate date] timeIntervalSince1970]], @"network": @"1", @"device": @"iphone3,2"};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:nil startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (error) {
[self appendLog:error.description];
} else {
[self appendLog:[NSString stringWithFormat:@": %@", result.description]];
}
}];
}
- (void)calculateTokenEveryRequest
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.builtinParameters = @{@"t": [NSString stringWithFormat:@"%lf", [[NSDate date] timeIntervalSince1970]], @"network": @"1", @"device": @"iphone3,2"};
[MGJRequestManager sharedInstance].configuration = configuration;
[MGJRequestManager sharedInstance].parametersHandler = ^(NSMutableDictionary *builtinParameters, NSMutableDictionary *requestParameters) {
NSString *builtinValues = [builtinParameters.allValues componentsJoinedByString:@""];
NSString *requestValues = [requestParameters.allValues componentsJoinedByString:@""];
NSString *md5Values = [self md5String:[NSString stringWithFormat:@"%@%@", builtinValues, requestValues]];
requestParameters[@"token"] = md5Values;
};
NSDictionary *requestParameters = @{@"user_id": @1024};
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:requestParameters
startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)preventFromSendingRequest
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.requestHandler = ^(AFHTTPRequestOperation *operation, id userInfo, BOOL *shouldStopProcessing){
// NSString *requestURL = operation.request.URL.absoluteString;
// suppose requestURL contains some invalid characters
*shouldStopProcessing = YES;
};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:nil startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:error.description];
}];
}
- (void)handleResponse
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.responseHandler = ^(AFHTTPRequestOperation *operation, id userInfo, MGJResponse *response, BOOL *shouldStopProcessing) {
// response.result object
// result error response.error
//
NSDictionary *args = response.result[@"args"];
if ([args[@"status"] isEqualToString:@"error"]) {
response.error = [NSError errorWithDomain:args[@"message"] code:403 userInfo:nil];
response.result = nil;
}
};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:@{@"status": @"error", @"message": @""} startImmediately:YES configurationHandler:nil completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (error) {
[self appendLog:error.description];
}
}];
}
- (void)handleSpecialRequest
{
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:nil
startImmediately:YES
configurationHandler:^(MGJRequestManagerConfiguration *configuration) {
configuration.requestHandler = ^(AFHTTPRequestOperation *operation, id userInfo, BOOL *shouldStopProcessing) {
//
*shouldStopProcessing = YES;
};
[self appendLog:@""];
}
completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (error.code == MGJResponseCancelError) {
[self appendLog:@""];
}
}];
}
- (void)chainRequests
{
AFHTTPRequestOperation *operation1 = [[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:@{@"method": @1}
startImmediately:NO
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
AFHTTPRequestOperation *operation2 = [[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:@{@"method": @2}
startImmediately:NO
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
[[MGJRequestManager sharedInstance] addOperation:operation1 toChain:@"chain"];
[[MGJRequestManager sharedInstance] addOperation:operation2 toChain:@"chain"];
}
- (void)runningRequests
{
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:@{@"method": @1}
startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:error.description];
}];
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:@{@"method": @2}
startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:error.description];
}];
[self appendLog:[[MGJRequestManager sharedInstance] runningRequests].description];
[[MGJRequestManager sharedInstance] cancelAllRequest];
}
- (void)cancelRequestByURL
{
NSString *urlString = @"path_to_url";
[[MGJRequestManager sharedInstance] GET:urlString
parameters:@{@"method": @1}
startImmediately:YES
configurationHandler:nil
completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:error.description];
}];
[[MGJRequestManager sharedInstance] cancelHTTPOperationsWithMethod:@"GET" url:urlString];
}
- (void)simulateTokenExpired
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.responseHandler = ^(AFHTTPRequestOperation *operation, id userInfo, MGJResponse *response, BOOL *shouldStopProcessing) {
static BOOL hasExecuted;
if (!hasExecuted) {
hasExecuted = YES;
*shouldStopProcessing = YES;
static BOOL hasGotRefreshToken = NO;
AFHTTPRequestOperation *refreshTokenRequestOperation = [[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:nil startImmediately:NO configurationHandler:nil completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (!error) {
[self appendLog:@"got refresh token"];
} else {
[self appendLog:[NSString stringWithFormat:@"refresh token fetch failed:%@", error]];
}
hasGotRefreshToken = YES;
}];
AFHTTPRequestOperation *reAssembledOperation = [[MGJRequestManager sharedInstance] reAssembleOperation:operation];
[[MGJRequestManager sharedInstance] addOperation:refreshTokenRequestOperation toChain:@"refreshToken"];
[[MGJRequestManager sharedInstance] addOperation:reAssembledOperation toChain:@"refreshToken"];
}
};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:nil startImmediately:YES configurationHandler:nil completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)showLoadingWhenSendingRequest
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicatorView.frame = CGRectMake(self.view.frame.size.width / 2 - 8, self.view.frame.size.height / 2 - 8, 16, 16);
[self.view addSubview:indicatorView];
configuration.requestHandler = ^(AFHTTPRequestOperation *operation, id userInfo, BOOL *shouldStopProcessing) {
if (userInfo[@"showLoading"]) {
[indicatorView startAnimating];
}
};
configuration.responseHandler = ^(AFHTTPRequestOperation *operation, id userInfo, MGJResponse *response, BOOL *shouldStopProcessing) {
if (userInfo[@"showLoading"]) {
[indicatorView stopAnimating];
}
};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url"
parameters:nil
startImmediately:YES
configurationHandler:^(MGJRequestManagerConfiguration *configuration){
configuration.userInfo = @{@"showLoading": @YES};
} completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)calculateRequestTime
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
configuration.responseHandler = ^(AFHTTPRequestOperation *operation, id userInfo, MGJResponse *response, BOOL *shouldStopProcessing) {
[self appendLog:[NSString stringWithFormat:@":%f ", [[NSDate date] timeIntervalSince1970] - startTime]];
};
[MGJRequestManager sharedInstance].configuration = configuration;
[[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:nil startImmediately:YES configurationHandler:^(MGJRequestManagerConfiguration *configuration){
// userInfo
} completionHandler:^(NSError *error, id<NSObject> result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
[self appendLog:result.description];
}];
}
- (void)uploadImage
{
UIImage *image = [UIImage imageNamed:@"warren.jpg"];
NSInteger positionX = self.resultTextView.frame.size.width / 2 - 121;
NSInteger positionY = self.resultTextView.frame.size.height / 2 - 80;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(positionX, positionY, 242, 160)];
[self.resultTextView addSubview:imageView];
// Demo APIKey
NSDictionary *parameters = @{
@"key": @"03CFKLSU25b1dddc62545683bad52f8796bb110c",
@"format": @"json",
};
[[MGJRequestManager sharedInstance] POST:@"path_to_url" parameters:parameters startImmediately:YES constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:UIImageJPEGRepresentation(image, 0.75) name:@"fileupload" fileName:@"image.jpg" mimeType:@"image/jpeg"];
} configurationHandler:nil completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (!error) {
[self appendLog:@"..."];
[imageView sd_setImageWithURL:[NSURL URLWithString:result[@"links"][@"image_link"]]];
} else {
[self appendLog:error.description];
}
}];
}
- (void)addHeaderValues
{
MGJRequestManagerConfiguration *configuration = [MGJRequestManager sharedInstance].configuration;
configuration.builtinParameters = @{@"operationSys":@"ios",@"requestTool":@"MGJ"};
[[MGJRequestManager sharedInstance] GET:@"path_to_url" parameters:nil startImmediately:YES configurationHandler:nil completionHandler:^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *operation) {
if (!error) {
[self appendLog:[result description]];
} else {
[self appendLog:error.description];
}
}];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/DemoDetailViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 4,776 |
```objective-c
//
// DemoListViewController.m
// MGJRequestManagerDemo
//
// Created by limboy on 3/20/15.
//
#import "DemoListViewController.h"
static NSMutableDictionary *titleWithHandlers;
static NSMutableArray *titles;
@interface DemoListViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic) UITableView *tableView;
@end
@implementation DemoListViewController
+ (void)registerWithTitle:(NSString *)title handler:(UIViewController *(^)())handler
{
if (!titleWithHandlers) {
titleWithHandlers = [[NSMutableDictionary alloc] init];
titles = [NSMutableArray array];
}
[titles addObject:title];
titleWithHandlers[title] = handler;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"MGJRequestManagerDemo";
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return titleWithHandlers.allKeys.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = titles[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIViewController *viewController = ((ViewControllerHandler)titleWithHandlers[titles[indexPath.row]])();
// NSLog(@"%@ -- %@ -- %@",titles[indexPath.row],titleWithHandlers[titles[indexPath.row]],((ViewControllerHandler)titleWithHandlers[titles[indexPath.row]]));
NSLog(@"%@",((ViewControllerHandler)titleWithHandlers[titles[indexPath.row]])());
[self.navigationController pushViewController:viewController animated:YES];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/DemoListViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 436 |
```objective-c
//
// YFAnimationsViewController.h
// BigShow1949
//
// Created by WangMengqi on 15/9/1.
//
#import <UIKit/UIKit.h>
@interface YFAnimationsViewController : BaseTableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/YFAnimationsViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 53 |
```objective-c
//
// YFAnimationsViewController.m
// BigShow1949
//
// Created by WangMengqi on 15/9/1.
//
#import "YFAnimationsViewController.h"
@implementation YFAnimationsViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDataArr:@[@[@"",@"YFPopMenuViewController"],
@[@"",@"YFEmitterViewController"],
@[@"",@"YFWaterWaveViewController"],
@[@"",@"YFBezierViewController"],
@[@"",@"YFCoreAnimationViewController"],
@[@"",@"YFPasswordShakeViewController"],]];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/YFAnimationsViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 128 |
```objective-c
//
// YFCoreAnimationViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "YFCoreAnimationViewController.h"
@interface YFCoreAnimationViewController ()
@end
@implementation YFCoreAnimationViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDataArr:@[@[@"",@"CoreAnimationViewController"],
@[@"3Dpush",@"YFPushTransitionViewController"],
@[@"",@"YFLoginTransitionViewController"],]];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/YFCoreAnimationViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 111 |
```objective-c
//
// YFCoreAnimationViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFCoreAnimationViewController : BaseTableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/YFCoreAnimationViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 54 |
```objective-c
//
// HyLoglnButton.h
// Example
//
// Created by on 15/9/2.
//
#import <UIKit/UIKit.h>
#import "SpinerLayer.h"
typedef void(^Completion)();
@interface HyLoglnButton : UIButton
@property (nonatomic,retain) SpinerLayer *spiner;
-(void)setCompletion:(Completion)completion;
-(void)StartAnimation;
-(void)ErrorRevertAnimationCompletion:(Completion)completion;
-(void)ExitAnimationCompletion:(Completion)completion;
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/HyLoglnButton.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 109 |
```objective-c
//
// MGJRequestManager.m
// MGJFoundation
//
// Created by limboy on 12/10/14.
//
#import "MGJRequestManager.h"
static NSString * const MGJRequestManagerCacheDirectory = @"requestCacheDirectory";
static NSString * const MGJFileProcessingQueue = @"MGJFileProcessingQueue";
NSInteger const MGJResponseCancelError = -1;
@implementation MGJResponse @end
#pragma mark - MGJResponseCache
@interface MGJResponseCache : NSObject
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key;
- (id <NSCoding>)objectForKey:(NSString *)key;
- (void)removeObjectForKey:(NSString *)key;
- (void)trimToDate:(NSDate *)date;
- (void)removeAllObjects;
@end
@implementation MGJResponseCache {
NSCache *_memoryCache;
NSFileManager *_fileManager;
NSString *_cachePath;
dispatch_queue_t _queue;
}
- (instancetype)init
{
self = [super init];
if (self) {
_memoryCache = [[NSCache alloc] init];
_queue = dispatch_queue_create([MGJFileProcessingQueue UTF8String], DISPATCH_QUEUE_CONCURRENT);
[self createCachesDirectory];
}
return self;
}
- (void)createCachesDirectory
{
_fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
_cachePath = [cachePath stringByAppendingPathComponent:MGJRequestManagerCacheDirectory];
BOOL isDirectory;
if (![_fileManager fileExistsAtPath:_cachePath isDirectory:&isDirectory]) {
__autoreleasing NSError *error = nil;
BOOL created = [_fileManager createDirectoryAtPath:_cachePath withIntermediateDirectories:YES attributes:nil error:&error];
if (!created) {
NSLog(@"<MGJRequestManager> - create cache directory failed with error:%@", error);
}
}
}
- (NSString *)encodedString:(NSString *)string
{
if (![string length])
return @"";
CFStringRef static const charsToEscape = CFSTR(".:/");
CFStringRef escapedString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(__bridge CFStringRef)string,
NULL,
charsToEscape,
kCFStringEncodingUTF8);
return (__bridge_transfer NSString *)escapedString;
}
- (NSString *)decodedString:(NSString *)string
{
if (![string length])
return @"";
CFStringRef unescapedString = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
(__bridge CFStringRef)string,
CFSTR(""),
kCFStringEncodingUTF8);
return (__bridge_transfer NSString *)unescapedString;
}
- (void)setObject:(id<NSCoding>)object forKey:(NSString *)key
{
NSString *encodedKey = [self encodedString:key];
[_memoryCache setObject:object forKey:key];
dispatch_async(_queue, ^{
NSString *filePath = [_cachePath stringByAppendingPathComponent:encodedKey];
BOOL written = [NSKeyedArchiver archiveRootObject:object toFile:filePath];
if (!written) {
NSLog(@"<MGJRequestManager> - set object to file failed");
}
});
}
- (id <NSCoding>)objectForKey:(NSString *)key
{
NSString *encodedKey = [self encodedString:key];
id<NSCoding> object = [_memoryCache objectForKey:encodedKey];
if (!object) {
NSString *filePath = [_cachePath stringByAppendingPathComponent:encodedKey];
if ([_fileManager fileExistsAtPath:filePath]) {
object = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
}
}
return object;
}
- (void)removeAllObjects
{
[_memoryCache removeAllObjects];
__autoreleasing NSError *error;
BOOL removed = [_fileManager removeItemAtPath:_cachePath error:&error];
if (!removed) {
NSLog(@"<MGJRequestManager> - remove cache directory failed with error:%@", error);
}
}
- (void)trimToDate:(NSDate *)date
{
__autoreleasing NSError *error = nil;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL URLWithString:_cachePath]
includingPropertiesForKeys:@[NSURLContentModificationDateKey]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:&error];
if (error) {
NSLog(@"<MGJRequestManager> - get files error:%@", error);
}
dispatch_async(_queue, ^{
for (NSURL *fileURL in files) {
NSDictionary *dictionary = [fileURL resourceValuesForKeys:@[NSURLContentModificationDateKey] error:nil];
NSDate *modificationDate = [dictionary objectForKey:NSURLContentModificationDateKey];
if (modificationDate.timeIntervalSince1970 - date.timeIntervalSince1970 < 0) {
[_fileManager removeItemAtPath:fileURL.absoluteString error:nil];
}
}
});
}
- (void)removeObjectForKey:(NSString *)key
{
NSString *encodedKey = [self encodedString:key];
[_memoryCache removeObjectForKey:encodedKey];
NSString *filePath = [_cachePath stringByAppendingPathComponent:encodedKey];
if ([_fileManager fileExistsAtPath:filePath]) {
__autoreleasing NSError *error = nil;
BOOL removed = [_fileManager removeItemAtPath:filePath error:&error];
if (!removed) {
NSLog(@"<MGJRequestManager> - remove item failed with error:%@", error);
}
}
}
@end
#pragma mark - MGJRequestManagerConfiguration
@implementation MGJRequestManagerConfiguration
- (AFHTTPRequestSerializer *)requestSerializer
{
return _requestSerializer ? : [AFHTTPRequestSerializer serializer];
}
- (AFHTTPResponseSerializer *)responseSerializer
{
return _responseSerializer ? : [AFJSONResponseSerializer serializer];
}
- (instancetype)copyWithZone:(NSZone *)zone
{
MGJRequestManagerConfiguration *configuration = [[MGJRequestManagerConfiguration alloc] init];
configuration.baseURL = [self.baseURL copy];
configuration.resultCacheDuration = self.resultCacheDuration;
configuration.builtinParameters = [self.builtinParameters copy];
configuration.userInfo = [self.userInfo copy];
configuration.builtinHeaders = [self.builtinParameters copy];
return configuration;
}
@end
#pragma mark - MGJRequestManager
@interface MGJRequestManager ()
@property (nonatomic) AFHTTPRequestOperationManager *requestManager;
@property (nonatomic) NSMutableDictionary *chainedOperations;
/**
* Operation Block
*/
@property (nonatomic) NSMapTable *completionBlocks;
/**
* Operation
*/
@property (nonatomic) NSMapTable *operationMethodParameters;
@property (nonatomic) MGJResponseCache *cache;
@property (nonatomic) NSMutableArray *batchGroups;
@end
@implementation MGJRequestManager
@synthesize configuration = _configuration;
+ (instancetype)sharedInstance
{
static MGJRequestManager *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (instancetype)init
{
self = [super init];
if (self) {
self.networkStatus = AFNetworkReachabilityStatusUnknown;
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
self.cache = [[MGJResponseCache alloc] init];
self.chainedOperations = [[NSMutableDictionary alloc] init];
self.completionBlocks = [NSMapTable mapTableWithKeyOptions:NSMapTableWeakMemory valueOptions:NSMapTableCopyIn];
self.operationMethodParameters = [NSMapTable mapTableWithKeyOptions:NSMapTableWeakMemory valueOptions:NSMapTableStrongMemory];
self.batchGroups = [[NSMutableArray alloc] init];
}
return self;
}
- (void)reachabilityChanged:(NSNotification *)notification
{
self.networkStatus = [notification.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue];
}
#pragma mark - Public
- (AFHTTPRequestOperation *)GET:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
return [self HTTPRequestOperationWithMethod:@"GET" URLString:URLString parameters:parameters startImmediately:startImmediately constructingBodyWithBlock:nil configurationHandler:configurationHandler completionHandler:completionHandler];
}
- (AFHTTPRequestOperation *)POST:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
return [self HTTPRequestOperationWithMethod:@"POST" URLString:URLString parameters:parameters startImmediately:startImmediately constructingBodyWithBlock:nil configurationHandler:configurationHandler completionHandler:completionHandler];
}
- (AFHTTPRequestOperation *)POST:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
return [self HTTPRequestOperationWithMethod:@"POST" URLString:URLString parameters:parameters startImmediately:startImmediately constructingBodyWithBlock:block configurationHandler:configurationHandler completionHandler:completionHandler];
}
- (AFHTTPRequestOperation *)PUT:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
return [self HTTPRequestOperationWithMethod:@"PUT" URLString:URLString parameters:parameters startImmediately:startImmediately constructingBodyWithBlock:nil configurationHandler:configurationHandler completionHandler:completionHandler];
}
- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
return [self HTTPRequestOperationWithMethod:@"DELETE" URLString:URLString parameters:parameters startImmediately:startImmediately constructingBodyWithBlock:nil configurationHandler:configurationHandler completionHandler:completionHandler];
}
- (AFHTTPRequestOperation *)HTTPRequestOperationWithMethod:(NSString *)method
URLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
startImmediately:(BOOL)startImmediately
constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block
configurationHandler:(MGJRequestManagerConfigurationHandler)configurationHandler
completionHandler:(MGJRequestManagerCompletionHandler)completionHandler
{
// configuration configuration
MGJRequestManagerConfiguration *configuration = [self.configuration copy];
if (configurationHandler) {
configurationHandler(configuration);
}
self.requestManager.requestSerializer = configuration.requestSerializer;
self.requestManager.responseSerializer = configuration.responseSerializer;
// parametersHandler builtin parameters request parameters
// token
if (self.parametersHandler) {
NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
NSMutableDictionary *mutableBultinParameters = [NSMutableDictionary dictionaryWithDictionary:configuration.builtinParameters];
self.parametersHandler(mutableParameters, mutableBultinParameters);
parameters = [mutableParameters copy];
configuration.builtinParameters = [mutableBultinParameters copy];
}
NSString *combinedURL = [URLString stringByAppendingString:[self serializeParams:configuration.builtinParameters]];
NSMutableURLRequest *request;
if (block) {
// block
request = [self.requestManager.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:combinedURL relativeToURL:[NSURL URLWithString:configuration.baseURL]] absoluteString] parameters:parameters constructingBodyWithBlock:block error:nil];
} else {
request = [self.requestManager.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:combinedURL relativeToURL:[NSURL URLWithString:configuration.baseURL]] absoluteString] parameters:parameters error:nil];
}
if (configuration.builtinHeaders.count > 0) {
for (NSString *key in configuration.builtinHeaders) {
[request setValue:configuration.builtinHeaders[key] forHTTPHeaderField:key];
}
}
// configuration request operation
AFHTTPRequestOperation *operation = [self createOperationWithConfiguration:configuration request:request];
//
if (!startImmediately) {
NSMutableDictionary *methodParameters = [NSMutableDictionary dictionaryWithDictionary:@{
@"method": method,
@"URLString": URLString,
}];
if (parameters) {
methodParameters[@"parameters"] = parameters;
}
if (block) {
methodParameters[@"constructingBodyWithBlock"] = block;
}
if (configurationHandler) {
methodParameters[@"configurationHandler"] = configurationHandler;
}
if (completionHandler) {
methodParameters[@"completionHandler"] = completionHandler;
}
[self.operationMethodParameters setObject:methodParameters forKey:operation];
return operation;
}
__weak typeof(self) weakSelf = self;
void (^checkIfShouldDoChainOperation)(AFHTTPRequestOperation *) = ^(AFHTTPRequestOperation *operation){
__strong typeof(self) strongSelf = weakSelf;
// TODO ChainedOperations
AFHTTPRequestOperation *nextOperation = [strongSelf findNextOperationInChainedOperationsBy:operation];
if (nextOperation) {
NSDictionary *methodParameters = [strongSelf.operationMethodParameters objectForKey:nextOperation];
if (methodParameters) {
[strongSelf HTTPRequestOperationWithMethod:methodParameters[@"method"]
URLString:methodParameters[@"URLString"]
parameters:methodParameters[@"parameters"]
startImmediately:YES
constructingBodyWithBlock:methodParameters[@"constructingBodyWithBlock"]
configurationHandler:methodParameters[@"configurationHandler"]
completionHandler:methodParameters[@"completionHandler"]];
[strongSelf.operationMethodParameters removeObjectForKey:nextOperation];
} else {
[strongSelf.requestManager.operationQueue addOperation:nextOperation];
}
}
};
// request
BOOL (^shouldStopProcessingRequest)(AFHTTPRequestOperation *, id userInfo, MGJRequestManagerConfiguration *) = ^BOOL (AFHTTPRequestOperation *operation, id userInfo, MGJRequestManagerConfiguration *configuration) {
BOOL shouldStopProcessing = NO;
//
if (weakSelf.configuration.requestHandler) {
weakSelf.configuration.requestHandler(operation, userInfo, &shouldStopProcessing);
}
// requestHandler
if (configuration.requestHandler) {
configuration.requestHandler(operation, userInfo, &shouldStopProcessing);
}
return shouldStopProcessing;
};
// response
MGJResponse *(^handleResponse)(AFHTTPRequestOperation *, id,BOOL) = ^ MGJResponse *(AFHTTPRequestOperation *theOperation, id responseObject,BOOL isFromCache) {
MGJResponse *response = [[MGJResponse alloc] init];
// a bit trick :)
response.error = [responseObject isKindOfClass:[NSError class]] ? responseObject : nil;
response.result = response.error ? nil : responseObject;
BOOL shouldStopProcessing = NO;
//
if (weakSelf.configuration.responseHandler) {
weakSelf.configuration.responseHandler(operation, configuration.userInfo, response, &shouldStopProcessing);
}
// responseHandler
if (configuration.responseHandler) {
configuration.responseHandler(operation, configuration.userInfo, response, &shouldStopProcessing);
}
// shouldStopProcessing , completionHandler
if (shouldStopProcessing) {
[weakSelf.completionBlocks removeObjectForKey:theOperation];
return response;
}
completionHandler(response.error, response.result, isFromCache, theOperation);
[weakSelf.completionBlocks removeObjectForKey:theOperation];
checkIfShouldDoChainOperation(theOperation);
return response;
};
//
if (configuration.resultCacheDuration > 0 && [method isEqualToString:@"GET"]) {
NSString *urlKey = [URLString stringByAppendingString:[self serializeParams:parameters]];
id result = [self.cache objectForKey:urlKey];
if (result) {
if (!shouldStopProcessingRequest(operation, configuration.userInfo, configuration)) {
handleResponse(operation, result, YES);
} else {
NSError *error = [NSError errorWithDomain:@"" code:MGJResponseCancelError userInfo:nil];
handleResponse(operation, error, NO);
}
return operation;
}
}
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *theOperation, id responseObject){
MGJResponse *response = handleResponse(theOperation, responseObject,NO);
//
if (configuration.resultCacheDuration > 0 && [method isEqualToString:@"GET"] && !response.error) {
// builtinParameters, builtin parameters
NSString *urlKey = [URLString stringByAppendingString:[self serializeParams:parameters]];
[weakSelf.cache setObject:response.result forKey:urlKey];
}
} failure:^(AFHTTPRequestOperation *theOperation, NSError *error){
handleResponse(theOperation, error,NO);
}];
if (!shouldStopProcessingRequest(operation, configuration.userInfo, configuration)) {
[self.requestManager.operationQueue addOperation:operation];
} else {
NSError *error = [NSError errorWithDomain:@"" code:MGJResponseCancelError userInfo:nil];
handleResponse(operation, error,NO);
}
[self.completionBlocks setObject:operation.completionBlock forKey:operation];
return operation;
}
- (AFHTTPRequestOperation *)startOperation:(AFHTTPRequestOperation *)operation
{
NSDictionary *methodParameters = [self.operationMethodParameters objectForKey:operation];
AFHTTPRequestOperation *newOperation = operation;
if (methodParameters) {
newOperation = [self HTTPRequestOperationWithMethod:methodParameters[@"method"]
URLString:methodParameters[@"URLString"]
parameters:methodParameters[@"parameters"]
startImmediately:YES
constructingBodyWithBlock:methodParameters[@"constructingBodyWithBlock"]
configurationHandler:methodParameters[@"configurationHandler"]
completionHandler:methodParameters[@"completionHandler"]];
[self.operationMethodParameters removeObjectForKey:operation];
} else {
[self.requestManager.operationQueue addOperation:operation];
}
return newOperation;
}
- (NSArray *)runningRequests
{
return self.requestManager.operationQueue.operations;
}
- (void)cancelAllRequest
{
[self.requestManager.operationQueue cancelAllOperations];
}
- (void)cancelHTTPOperationsWithMethod:(NSString *)method url:(NSString *)url
{
NSError *error;
NSString *pathToBeMatched = [[[self.requestManager.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:url] absoluteString] parameters:nil error:&error] URL] path];
for (NSOperation *operation in [self.requestManager.operationQueue operations]) {
if (![operation isKindOfClass:[AFHTTPRequestOperation class]]) {
continue;
}
BOOL hasMatchingMethod = !method || [method isEqualToString:[[(AFHTTPRequestOperation *)operation request] HTTPMethod]];
BOOL hasMatchingPath = [[[[(AFHTTPRequestOperation *)operation request] URL] path] isEqual:pathToBeMatched];
if (hasMatchingMethod && hasMatchingPath) {
[operation cancel];
}
}
}
- (void)addOperation:(AFHTTPRequestOperation *)operation toChain:(NSString *)chain
{
NSString *chainName = chain ? : @"";
if (!self.chainedOperations[chainName]) {
self.chainedOperations[chainName] = [[NSMutableArray alloc] init];
}
//
if (!((NSMutableArray *)self.chainedOperations[chainName]).count) {
operation = [self startOperation:operation];
}
[self.chainedOperations[chainName] addObject:operation];
}
- (NSArray *)operationsInChain:(NSString *)chain
{
return self.chainedOperations[chain];
}
- (void)removeOperation:(AFHTTPRequestOperation *)operation inChain:(NSString *)chain
{
NSString *chainName = chain ? : @"";
if (self.chainedOperations[chainName]) {
NSMutableArray *chainedOperations = self.chainedOperations[chainName];
[chainedOperations removeObject:operation];
}
}
- (void)removeOperationsInChain:(NSString *)chain
{
NSString *chainName = chain ? : @"";
NSMutableArray *chainedOperations = self.chainedOperations[chainName];
chainedOperations ? [chainedOperations removeAllObjects] : @"do nothing";
}
- (void)batchOfRequestOperations:(NSArray *)operations
progressBlock:(void (^)(NSUInteger, NSUInteger))progressBlock
completionBlock:(void (^)())completionBlock
{
__block dispatch_group_t group = dispatch_group_create();
[self.batchGroups addObject:group];
__block NSInteger finishedOperationsCount = 0;
NSInteger totalOperationsCount = operations.count;
[operations enumerateObjectsUsingBlock:^(AFHTTPRequestOperation *operation, NSUInteger idx, BOOL *stop) {
NSMutableDictionary *operationMethodParameters = [NSMutableDictionary dictionaryWithDictionary:[self.operationMethodParameters objectForKey:operation]];
if (operationMethodParameters) {
dispatch_group_enter(group);
MGJRequestManagerCompletionHandler originCompletionHandler = [(MGJRequestManagerCompletionHandler) operationMethodParameters[@"completionHandler"] copy];
MGJRequestManagerCompletionHandler newCompletionHandler = ^(NSError *error, id result, BOOL isFromCache, AFHTTPRequestOperation *theOperation) {
if (!isFromCache) {
if (progressBlock) {
progressBlock(++finishedOperationsCount, totalOperationsCount);
}
}
dispatch_async(dispatch_get_main_queue(), ^{
if (originCompletionHandler) {
originCompletionHandler(error, result, isFromCache, theOperation);
}
dispatch_group_leave(group);
});
};
operationMethodParameters[@"completionHandler"] = newCompletionHandler;
[self.operationMethodParameters setObject:operationMethodParameters forKey:operation];
[self startOperation:operation];
}
}];
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
[self.batchGroups removeObject:group];
if (completionBlock) {
completionBlock();
}
});
}
- (AFHTTPRequestOperation *)reAssembleOperation:(AFHTTPRequestOperation *)operation
{
AFHTTPRequestOperation *newOperation = [operation copy];
newOperation.completionBlock = [self.completionBlocks objectForKey:operation];
//
[self.completionBlocks removeObjectForKey:operation];
return newOperation;
}
#pragma mark - Utils
/**
* Chained Operations Operation Operation
* Chain Operation!
*/
- (AFHTTPRequestOperation *)findNextOperationInChainedOperationsBy:(AFHTTPRequestOperation *)operation
{
//TODO
__block AFHTTPRequestOperation *theOperation;
__weak typeof(self) weakSelf = self;
[self.chainedOperations enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSMutableArray *chainedOperations, BOOL *stop) {
[chainedOperations enumerateObjectsUsingBlock:^(AFHTTPRequestOperation *requestOperation, NSUInteger idx, BOOL *stop) {
if (requestOperation == operation) {
if (idx < chainedOperations.count - 1) {
theOperation = chainedOperations[idx + 1];
*stop = YES;
}
[chainedOperations removeObject:requestOperation];
// operation
[chainedOperations removeObject:theOperation];
}
}];
if (chainedOperations) {
*stop = YES;
}
if (!chainedOperations.count) {
[weakSelf.chainedOperations removeObjectForKey:key];
}
}];
return theOperation;
}
- (AFHTTPRequestOperationManager *)requestManager
{
if (!_requestManager) {
_requestManager = [AFHTTPRequestOperationManager manager] ;
}
return _requestManager;
}
- (MGJRequestManagerConfiguration *)configuration
{
if (!_configuration) {
_configuration = [[MGJRequestManagerConfiguration alloc] init];
}
return _configuration;
}
- (void)setConfiguration:(MGJRequestManagerConfiguration *)configuration
{
if (_configuration != configuration) {
_configuration = configuration;
if (_configuration.resultCacheDuration > 0) {
double pastTimeInterval = [[NSDate date] timeIntervalSince1970] - _configuration.resultCacheDuration;
NSDate *pastDate = [NSDate dateWithTimeIntervalSince1970:pastTimeInterval];
[self.cache trimToDate:pastDate];
}
}
}
- (AFHTTPRequestOperation *)createOperationWithConfiguration:(MGJRequestManagerConfiguration *)configuration request:(NSURLRequest *)request
{
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = self.requestManager.responseSerializer;
operation.shouldUseCredentialStorage = self.requestManager.shouldUseCredentialStorage;
operation.credential = self.requestManager.credential;
operation.securityPolicy = self.requestManager.securityPolicy;
operation.completionQueue = self.requestManager.completionQueue;
operation.completionGroup = self.requestManager.completionGroup;
return operation;
}
-(NSString *)serializeParams:(NSDictionary *)params {
NSMutableArray *parts = [NSMutableArray array];
[params enumerateKeysAndObjectsUsingBlock:^(id key, id<NSObject> obj, BOOL *stop) {
NSString *encodedKey = [key stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString *encodedValue = [obj.description stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString *part = [NSString stringWithFormat: @"%@=%@", encodedKey, encodedValue];
[parts addObject: part];
}];
NSString *queryString = [parts componentsJoinedByString: @"&"];
return queryString ? [NSString stringWithFormat:@"?%@", queryString] : @"";
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/13 - YFNetworkRequest(网络请求)/MGJ/MGJRequestManager.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 5,458 |
```objective-c
//
// HyTransitions.m
// Example
//
// Created by on 15/9/2.
//
#import "HyTransitions.h"
@interface HyTransitions ()
@property (nonatomic,assign) NSTimeInterval transitionDuration;
@property (nonatomic,assign) CGFloat startingAlpha;
@property (nonatomic,assign) BOOL is;
@property (nonatomic,retain) id transitionContext;
@end
@implementation HyTransitions
-(instancetype) initWithTransitionDuration:(NSTimeInterval)transitionDuration StartingAlpha:(CGFloat)startingAlpha isBOOL:(BOOL)is{
self = [super init];
if (self) {
_transitionDuration = transitionDuration;
_startingAlpha = startingAlpha;
_is = is;
}
return self;
}
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext{
return _transitionDuration;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext{
UIView *containerView = [transitionContext containerView];
UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view;
UIView *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view;
if (_is) {
toView.alpha = _startingAlpha;
fromView.alpha = 1.0f;
[containerView addSubview:toView];
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toView.alpha = 1.0f;
fromView.alpha = 0.0f;
} completion:^(BOOL finished) {
fromView.alpha = 1.0f;
[transitionContext completeTransition:true];
}];
}else{
fromView.alpha = 1.0f;
toView.alpha = 0;
fromView.transform = CGAffineTransformMakeScale(1, 1);
[containerView addSubview:toView];
[UIView animateWithDuration:0.3 animations:^{
fromView.transform = CGAffineTransformMakeScale(3, 3);
fromView.alpha = 0.0f;
toView.alpha = 1.0f;
} completion:^(BOOL finished) {
fromView.alpha = 1.0f;
[transitionContext completeTransition:true];
}];
}
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/HyTransitions.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 479 |
```objective-c
//
// YFLoginSecondViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFLoginSecondViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/YFLoginSecondViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// SpinerLayer.h
// Example
//
// Created by on 15/9/2.
//
#import <QuartzCore/QuartzCore.h>
@interface SpinerLayer : CAShapeLayer
-(instancetype) initWithFrame:(CGRect)frame;
-(void)animation;
-(void)stopAnimation;
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/SpinerLayer.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 69 |
```objective-c
//
// SpinerLayer.m
// Example
//
// Created by on 15/9/2.
//
#import "SpinerLayer.h"
#import <UIKit/UIKit.h>
@implementation SpinerLayer
-(instancetype) initWithFrame:(CGRect)frame{
self = [super init];
if (self) {
CGFloat radius = (CGRectGetHeight(frame) / 2) * 0.5;
self.frame = CGRectMake(0, 0, CGRectGetHeight(frame), CGRectGetHeight(frame));
CGPoint center = CGPointMake(CGRectGetHeight(frame) / 2, CGRectGetMidY(self.bounds));
CGFloat startAngle = 0 - M_PI_2;
CGFloat endAngle = M_PI * 2 - M_PI_2;
BOOL clockwise = true;
self.path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:clockwise].CGPath;
self.fillColor = nil;
self.strokeColor = [UIColor whiteColor].CGColor;
self.lineWidth = 1;
self.strokeEnd = 0.4;
self.hidden = true;
}
return self;
}
-(void)animation{
self.hidden = false;
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotate.fromValue = 0;
rotate.toValue = @(M_PI * 2);
rotate.duration = 0.4;
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
rotate.repeatCount = HUGE;
rotate.fillMode = kCAFillModeForwards;
rotate.removedOnCompletion = false;
[self addAnimation:rotate forKey:rotate.keyPath];
}
-(void)stopAnimation{
self.hidden = true;
[self removeAllAnimations];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/SpinerLayer.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 388 |
```objective-c
//
// YFLoginSecondViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "YFLoginSecondViewController.h"
@interface YFLoginSecondViewController ()
@end
@implementation YFLoginSecondViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:54./256. green:70./256. blue:93./256. alpha:1.];
[self createCloseButton];
}
- (void)createCloseButton
{
UIImageView *imageview= [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:imageview];
imageview.image = [UIImage imageNamed:@"Home"];
UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didCloseButtonTouch)];
[imageview setUserInteractionEnabled:true];
[imageview addGestureRecognizer:tap];
}
- (void)didCloseButtonTouch
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/YFLoginSecondViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 215 |
```objective-c
//
// YFLoginTransitionViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "YFLoginTransitionViewController.h"
#import "YFLoginSecondViewController.h"
#import "HyTransitions.h"
#import "HyLoglnButton.h"
@interface YFLoginTransitionViewController ()<UIViewControllerTransitioningDelegate>
@property (nonatomic, strong) UISwitch *Switch;
@end
@implementation YFLoginTransitionViewController
- (void)viewDidLoad {
[super viewDidLoad];
// imageView
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, YFScreen.width, YFScreen.height)];
imgView.image = [UIImage imageNamed:@"Login"];
[self.view addSubview:imgView];
// Switch
CGFloat switchW = 60;
CGFloat switchH = 40;
CGFloat padding = 10;
UISwitch *Switch = [[UISwitch alloc] initWithFrame:CGRectMake(YFScreen.width - switchW - padding, YFScreen.height - switchH - padding, switchW, switchH)];
[self.view addSubview:Switch];
self.Switch = Switch;
// button
[self createPresentControllerButton];
}
-(void)createPresentControllerButton{
HyLoglnButton *log = [[HyLoglnButton alloc] initWithFrame:CGRectMake(20, CGRectGetHeight(self.view.bounds) - (40 + 80), [UIScreen mainScreen].bounds.size.width - 40, 40)];
[log setBackgroundColor:[UIColor colorWithRed:1 green:0.f/255.0f blue:128.0f/255.0f alpha:1]];
[self.view addSubview:log];
[log setTitle:@"" forState:UIControlStateNormal];
[log addTarget:self action:@selector(PresentViewController:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)PresentViewController:(HyLoglnButton *)button{
typeof(self) __weak weak = self;
//
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weak LoginButton:button];
});
}
-(void)LoginButton:(HyLoglnButton *)button
{
typeof(self) __weak weak = self;
if (_Switch.on) {
//
[button ExitAnimationCompletion:^{
if (weak.Switch.on) {
[weak didPresentControllerButtonTouch];
}
}];
}else{
//
[button ErrorRevertAnimationCompletion:^{
if (weak.Switch.on) {
[weak didPresentControllerButtonTouch];
}
}];
}
}
- (void)didPresentControllerButtonTouch
{
UIViewController *controller = [YFLoginSecondViewController new];
controller.transitioningDelegate = self;
UINavigationController *nai = [[UINavigationController alloc] initWithRootViewController:controller];
nai.transitioningDelegate = self;
[self presentViewController:nai animated:YES completion:nil];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
return [[HyTransitions alloc]initWithTransitionDuration:0.4f StartingAlpha:0.5f isBOOL:true];
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
return [[HyTransitions alloc]initWithTransitionDuration:0.4f StartingAlpha:0.8f isBOOL:false];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/YFLoginTransitionViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 739 |
```objective-c
//
// YFLoginTransitionViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFLoginTransitionViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/YFLoginTransitionViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// HyTransitions.h
// Example
//
// Created by on 15/9/2.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface HyTransitions : NSObject <UIViewControllerAnimatedTransitioning>
-(instancetype) initWithTransitionDuration:(NSTimeInterval)transitionDuration StartingAlpha:(CGFloat)startingAlpha isBOOL:(BOOL)is;
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/HyTransitions.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 80 |
```objective-c
//
// CATransformViewController.m
// BigShow1949
//
// Created by apple on 16/10/26.
//
#import "CATransformViewController.h"
@interface CATransformViewController ()
@end
@implementation CATransformViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (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/07 - Animations(动画)/核心动画/核心动画基础篇/CATransformViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 164 |
```objective-c
//
// CAKeyframeAnimationViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface CAKeyframeAnimationViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CAKeyframeAnimationViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 52 |
```objective-c
//
// CABasicAnimationViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/21.
//
#import "CABasicAnimationViewController.h"
@interface CABasicAnimationViewController ()
@property(nonatomic,strong)CALayer *myLayer;
@end
@implementation CABasicAnimationViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
//layer
CALayer *myLayer=[CALayer layer];
//layer
myLayer.bounds=CGRectMake(0, 150, 50, 80);
myLayer.backgroundColor=[UIColor yellowColor].CGColor;
myLayer.position=CGPointMake(50, 64);
myLayer.anchorPoint=CGPointMake(0, 0);
myLayer.cornerRadius=20;
//layer
[self.view.layer addSublayer:myLayer];
self.myLayer=myLayer;
}
//
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//1.
// CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:<#(NSString *)#>]
CABasicAnimation *anima=[CABasicAnimation animation];
//1.1
anima.keyPath=@"position";
//layer
anima.fromValue=[NSValue valueWithCGPoint:CGPointMake(0, 64)];
anima.toValue=[NSValue valueWithCGPoint:CGPointMake(200, 300)];
//1.2
anima.removedOnCompletion=NO;
//1.3
anima.fillMode=kCAFillModeForwards;
//2.layer
[self.myLayer addAnimation:anima forKey:nil];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CABasicAnimationViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 368 |
```objective-c
//
// HyLoglnButton.m
// Example
//
// Created by on 15/9/2.
//
#import "HyLoglnButton.h"
@interface HyLoglnButton ()
@property (nonatomic,assign) CFTimeInterval shrinkDuration;
@property (nonatomic,retain) CAMediaTimingFunction *shrinkCurve;
@property (nonatomic,retain) CAMediaTimingFunction *expandCurve;
@property (nonatomic,strong) Completion block;
@property (nonatomic,retain) UIColor *color;
@end
@implementation HyLoglnButton
-(instancetype) initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
_spiner = [[SpinerLayer alloc] initWithFrame:self.frame];
_shrinkCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
_expandCurve = [CAMediaTimingFunction functionWithControlPoints:0.95 :0.02 :1 :0.05];
self.shrinkDuration = 0.1;
[self.layer addSublayer:_spiner];
[self setup];
}
return self;
}
-(void)setCompletion:(Completion)completion
{
_block = completion;
}
-(void)setup{
self.layer.cornerRadius = CGRectGetHeight(self.bounds) / 2;
self.clipsToBounds = true;
[self addTarget:self action:@selector(scaleToSmall)
forControlEvents:UIControlEventTouchDown | UIControlEventTouchDragEnter];
[self addTarget:self action:@selector(scaleAnimation)
forControlEvents:UIControlEventTouchUpInside];
[self addTarget:self action:@selector(scaleToDefault)
forControlEvents:UIControlEventTouchDragExit];
}
- (void)scaleToSmall
{
typeof(self) __weak weak = self;
self.transform = CGAffineTransformMakeScale(1, 1);
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
weak.transform = CGAffineTransformMakeScale(0.9, 0.9);
} completion:^(BOOL finished) {
}];
}
- (void)scaleAnimation
{
typeof(self) __weak weak = self;
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
weak.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
}];
[self StartAnimation];
}
- (void)scaleToDefault
{
typeof(self) __weak weak = self;
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.4f options:UIViewAnimationOptionLayoutSubviews animations:^{
weak.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
}];
}
-(void)StartAnimation{
[self performSelector:@selector(Revert) withObject:nil afterDelay:0.f];
[self.layer addSublayer:_spiner];
CABasicAnimation *shrinkAnim = [CABasicAnimation animationWithKeyPath:@"bounds.size.width"];
shrinkAnim.fromValue = @(CGRectGetWidth(self.bounds));
shrinkAnim.toValue = @(CGRectGetHeight(self.bounds));
shrinkAnim.duration = _shrinkDuration;
shrinkAnim.timingFunction = _shrinkCurve;
shrinkAnim.fillMode = kCAFillModeForwards;
shrinkAnim.removedOnCompletion = false;
[self.layer addAnimation:shrinkAnim forKey:shrinkAnim.keyPath];
[_spiner animation];
[self setUserInteractionEnabled:false];
}
-(void)ErrorRevertAnimationCompletion:(Completion)completion
{
_block = completion;
CABasicAnimation *shrinkAnim = [CABasicAnimation animationWithKeyPath:@"bounds.size.width"];
shrinkAnim.fromValue = @(CGRectGetHeight(self.bounds));
shrinkAnim.toValue = @(CGRectGetWidth(self.bounds));
shrinkAnim.duration = _shrinkDuration;
shrinkAnim.timingFunction = _shrinkCurve;
shrinkAnim.fillMode = kCAFillModeForwards;
shrinkAnim.removedOnCompletion = false;
_color = self.backgroundColor;
CABasicAnimation *backgroundColor = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
backgroundColor.toValue = (__bridge id)[UIColor redColor].CGColor;
backgroundColor.duration = 0.1f;
backgroundColor.timingFunction = _shrinkCurve;
backgroundColor.fillMode = kCAFillModeForwards;
backgroundColor.removedOnCompletion = false;
CAKeyframeAnimation *keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGPoint point = self.layer.position;
keyFrame.values = @[[NSValue valueWithCGPoint:CGPointMake(point.x, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x - 10, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x + 10, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x - 10, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x + 10, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x - 10, point.y)],
[NSValue valueWithCGPoint:CGPointMake(point.x + 10, point.y)],
[NSValue valueWithCGPoint:point]];
keyFrame.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
keyFrame.duration = 0.5f;
keyFrame.delegate = self;
self.layer.position = point;
[self.layer addAnimation:backgroundColor forKey:backgroundColor.keyPath];
[self.layer addAnimation:keyFrame forKey:keyFrame.keyPath];
[self.layer addAnimation:shrinkAnim forKey:shrinkAnim.keyPath];
[_spiner stopAnimation];
[self setUserInteractionEnabled:true];
}
-(void)ExitAnimationCompletion:(Completion)completion{
_block = completion;
CABasicAnimation *expandAnim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
expandAnim.fromValue = @(1.0);
expandAnim.toValue = @(33.0);
expandAnim.timingFunction = _expandCurve;
expandAnim.duration = 0.3;
expandAnim.delegate = self;
expandAnim.fillMode = kCAFillModeForwards;
expandAnim.removedOnCompletion = false;
[self.layer addAnimation:expandAnim forKey:expandAnim.keyPath];
[_spiner stopAnimation];
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
CABasicAnimation *cab = (CABasicAnimation *)anim;
if ([cab.keyPath isEqualToString:@"transform.scale"]) {
[self setUserInteractionEnabled:true];
if (_block) {
_block();
}
[NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(DidStopAnimation) userInfo:nil repeats:nil];
}
}
-(void)Revert{
CABasicAnimation *backgroundColor = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
backgroundColor.toValue = (__bridge id)self.backgroundColor.CGColor;
backgroundColor.duration = 0.1f;
backgroundColor.timingFunction = _shrinkCurve;
backgroundColor.fillMode = kCAFillModeForwards;
backgroundColor.removedOnCompletion = false;
[self.layer addAnimation:backgroundColor forKey:@"backgroundColors"];
}
-(void)DidStopAnimation{
[self.layer removeAllAnimations];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/登陆转场动画/HyLoglnButton.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,622 |
```objective-c
//
// CATransitionViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "CATransitionViewController.h"
@interface CATransitionViewController ()
@property(nonatomic,assign) int index;
@property (nonatomic, strong) UIImageView *imgView;
@end
@implementation CATransitionViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)];
imgView.center = CGPointMake(YFScreen.width / 2, YFScreen.width / 2 + 100);
imgView.image = [UIImage imageNamed:@"Transition0.jpg"];
self.imgView = imgView;
[self.view addSubview:imgView];
UIButton *nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(100, CGRectGetMaxY(imgView.frame) + 50, 100, 50)];
[nextBtn setTitle:@"" forState:UIControlStateNormal];
nextBtn.backgroundColor = [UIColor lightGrayColor];
[nextBtn addTarget:self action:@selector(text) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:nextBtn];
// self.index=1;
}
- (void)text {
self.index++;
if (self.index>3) {
self.index=0;
}
self.imgView.image=[UIImage imageNamed: [NSString stringWithFormat:@"Transition%d.jpg",self.index]];
//1.
CATransition *ca=[CATransition animation];
//1.1
//1.2
ca.type=@"cube";
//1.3
ca.subtype=kCATransitionFromRight;
//1.4
ca.duration=2.0;
//1.5
ca.startProgress=0.5;
//1.6
// ca.endProgress=0.5;
//2.
[self.imgView.layer addAnimation:ca forKey:nil];
}
//- (IBAction)preOnClick:(UIButton *)sender {
// self.index--;
// if (self.index<1) {
// self.index=7;
// }
// self.iconView.image=[UIImage imageNamed: [NSString stringWithFormat:@"%d.jpg",self.index]];
//
// //
// CATransition *ca=[CATransition animation];
// //
// //
// ca.type=@"cube";
// //
// ca.subtype=kCATransitionFromLeft;
// //
// ca.duration=2.0;
// //
// [self.iconView.layer addAnimation:ca forKey:nil];
//}
//
////
//- (IBAction)nextOnClick:(UIButton *)sender {
// self.index++;
// if (self.index>7) {
// self.index=1;
// }
// self.iconView.image=[UIImage imageNamed: [NSString stringWithFormat:@"%d.jpg",self.index]];
//
// //1.
// CATransition *ca=[CATransition animation];
//
// //1.1
// //1.2
// ca.type=@"cube";
// //1.3
// ca.subtype=kCATransitionFromRight;
// //1.4
// ca.duration=2.0;
// //1.5
// ca.startProgress=0.5;
// //1.6
// // ca.endProgress=0.5;
//
// //2.
// [self.iconView.layer addAnimation:ca forKey:nil];
//}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CATransitionViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 737 |
```objective-c
//
// CABasicAnimationViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/21.
//
#import <UIKit/UIKit.h>
@interface CABasicAnimationViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CABasicAnimationViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 50 |
```objective-c
//
// CAAnimationGroupViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface CAAnimationGroupViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CAAnimationGroupViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 50 |
```objective-c
//
// CAAnimationGroupViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "CAAnimationGroupViewController.h"
@interface CAAnimationGroupViewController ()
@property (nonatomic, strong) UIView *iconView;
@end
@implementation CAAnimationGroupViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIView *iconView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
iconView.backgroundColor = [UIColor redColor];
self.iconView = iconView;
[self.view addSubview:iconView];
//
CABasicAnimation *a1 = [CABasicAnimation animation];
a1.keyPath = @"transform.translation.y";
a1.toValue = @(100);
//
CABasicAnimation *a2 = [CABasicAnimation animation];
a2.keyPath = @"transform.scale";
a2.toValue = @(0.0);
//
CABasicAnimation *a3 = [CABasicAnimation animation];
a3.keyPath = @"transform.rotation";
a3.toValue = @(M_PI_2);
//
CAAnimationGroup *groupAnima = [CAAnimationGroup animation];
groupAnima.animations = @[a1, a2, a3];
//
groupAnima.duration = 2;
groupAnima.fillMode = kCAFillModeForwards;
groupAnima.removedOnCompletion = NO;
[self.iconView.layer addAnimation:groupAnima forKey:nil];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CAAnimationGroupViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 346 |
```objective-c
//
// CoreAnimationViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/21.
//
#import "CoreAnimationViewController.h"
/*
* :path_to_url
*/
@interface CoreAnimationViewController ()
@end
@implementation CoreAnimationViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDataArr:@[@[@"",@"CABasicAnimationViewController"],
@[@"",@"CAKeyframeAnimationViewController"],
@[@"",@"CATransitionViewController"],
@[@"",@"CAAnimationGroupViewController"],
@[@"Transform",@"CATransformViewController_UIStoryboard"],]];
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CoreAnimationViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 130 |
```objective-c
//
// CATransformViewController.h
// BigShow1949
//
// Created by apple on 16/10/26.
//
#import <UIKit/UIKit.h>
@interface CATransformViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CATransformViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 48 |
```objective-c
//
// CoreAnimationViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/21.
//
#import "BaseTableViewController.h"
@interface CoreAnimationViewController : BaseTableViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CoreAnimationViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 51 |
```objective-c
//
// CATransitionViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface CATransitionViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CATransitionViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 48 |
```objective-c
//
// KYPopTransition.m
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/19/15.
//
#import "KYPopTransition.h"
@interface KYPopTransition()
@property (nonatomic,strong)id<UIViewControllerContextTransitioning> transitionContext;
@end
@implementation KYPopTransition
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext{
return 0.6f;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext{
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *fromView = fromVC.view;
UIView *toView = toVC.view;
UIView *containerView = [transitionContext containerView];
[containerView addSubview:toView];
//transform
CATransform3D transform = CATransform3DIdentity;
transform.m34 = -0.002;
containerView.layer.sublayerTransform = transform;
//fromVCtoVCframe
CGRect initialFrame = [transitionContext initialFrameForViewController:fromVC];
fromView.frame = initialFrame;
toView.frame = initialFrame;
//View
[self updateAnchorPointAndOffset:CGPointMake(0.0, 0.5) view:toView];
//toView90
toView.layer.transform = CATransform3DMakeRotation(-M_PI_2, 0.0, 1.0, 0.0);
[UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
//fromView 90
toView.layer.transform = CATransform3DMakeRotation(0, 0, 1.0, 0);
} completion:^(BOOL finished) {
toView.layer.anchorPoint = CGPointMake(0.5, 0.5);
toView.layer.position = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds));
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
//View
-(void)updateAnchorPointAndOffset:(CGPoint)anchorPoint view:(UIView *)view{
view.layer.anchorPoint = anchorPoint;
view.layer.position = CGPointMake(0, CGRectGetMidY([UIScreen mainScreen].bounds));
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPopTransition.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 534 |
```objective-c
//
// KYPopInteractiveTransition.h
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/19/15.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface KYPopInteractiveTransition : UIPercentDrivenInteractiveTransition
@property(nonatomic,assign)BOOL interacting;
-(void)addPopGesture:(UIViewController *)viewController;
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPopInteractiveTransition.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 82 |
```objective-c
//
// CAKeyframeAnimationViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "CAKeyframeAnimationViewController.h"
#define angle2Radian(angle) ((angle)/180.0*M_PI)
@interface CAKeyframeAnimationViewController ()
@property (nonatomic, strong) UILabel *customView;
@property (nonatomic, strong) UISegmentedControl *segmentedControl;
@end
@implementation CAKeyframeAnimationViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// label
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
label.text = @"";
label.backgroundColor = [UIColor blueColor];
self.customView = label;
[self.view addSubview:label];
// rightBarButtonItem
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(stop)];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"one", @"two", @"three"]];
segmentedControl.frame = CGRectMake(0, 0, 150, 44);
segmentedControl.center = CGPointMake(YFScreen.width / 2, 100);
[segmentedControl addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
// self.segmentedControl = segmentedControl;
[self.view addSubview:segmentedControl];
}
- (void)test:(UISegmentedControl *)segmentedControl {
if (segmentedControl.selectedSegmentIndex == 0) {
[self test1];
}else if (segmentedControl.selectedSegmentIndex == 1) {
[self test2];
}else if (segmentedControl.selectedSegmentIndex == 2) {
[self test3];
}
}
- (void)test1 {
//1.
CAKeyframeAnimation *keyAnima=[CAKeyframeAnimation animation];
//
keyAnima.keyPath=@"position";
//1.1
NSValue *value1=[NSValue valueWithCGPoint:CGPointMake(100, 100)];
NSValue *value2=[NSValue valueWithCGPoint:CGPointMake(200, 100)];
NSValue *value3=[NSValue valueWithCGPoint:CGPointMake(200, 200)];
NSValue *value4=[NSValue valueWithCGPoint:CGPointMake(100, 200)];
NSValue *value5=[NSValue valueWithCGPoint:CGPointMake(100, 100)];
keyAnima.values=@[value1,value2,value3,value4,value5];
//1.2
keyAnima.removedOnCompletion=NO;
//1.3
keyAnima.fillMode=kCAFillModeForwards;
//1.4
keyAnima.duration=4.0;
//1.5
keyAnima.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//
keyAnima.delegate=self;
//2.
[self.customView.layer addAnimation:keyAnima forKey:@"test"];
}
- (void)test2 {
//1.
CAKeyframeAnimation *keyAnima=[CAKeyframeAnimation animation];
//
keyAnima.keyPath=@"position";
//1.1
//
CGMutablePathRef path=CGPathCreateMutable();
//
CGPathAddEllipseInRect(path, NULL, CGRectMake(150, 100, 100, 100));
keyAnima.path=path;
//createrelease
CGPathRelease(path);
//1.2
keyAnima.removedOnCompletion=NO;
//1.3
keyAnima.fillMode=kCAFillModeForwards;
//1.4
keyAnima.duration=5.0;
//1.5
keyAnima.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//
keyAnima.delegate=self;
//2.
[self.customView.layer addAnimation:keyAnima forKey:@"test"];
}
- (void)test3 {
//1.
CAKeyframeAnimation *keyAnima=[CAKeyframeAnimation animation];
keyAnima.keyPath=@"transform.rotation";
//
keyAnima.duration=0.1;
//
// /180*M_PI
keyAnima.values=@[@(-angle2Radian(4)),@(angle2Radian(4)),@(-angle2Radian(4))];
//()
keyAnima.repeatCount= 29; //MAXFLOAT;
keyAnima.fillMode=kCAFillModeForwards;
keyAnima.removedOnCompletion=NO;
//2.
[self.customView.layer addAnimation:keyAnima forKey:@"test"];
}
- (void)stop {
//self.customView.layer test
[self.customView.layer removeAnimationForKey:@"test"];
}
-(void)animationDidStart:(CAAnimation *)anim
{
NSLog(@"");
}
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"");
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/核心动画基础篇/CAKeyframeAnimationViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 1,103 |
```objective-c
//
// KYPopTransition.h
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/19/15.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface KYPopTransition : NSObject<UIViewControllerAnimatedTransitioning>
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPopTransition.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 62 |
```objective-c
//
// YFPushTransitionViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFPushTransitionViewController : UIViewController<UIViewControllerTransitioningDelegate,UINavigationControllerDelegate>
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/YFPushTransitionViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 60 |
```objective-c
//
// YFSecondPushViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "YFSecondPushViewController.h"
@interface YFSecondPushViewController ()
@end
@implementation YFSecondPushViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blueColor];
}
- (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/07 - Animations(动画)/核心动画/3D翻转push跳转/YFSecondPushViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 171 |
```objective-c
//
// KYPopInteractiveTransition.m
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/19/15.
//
#import "KYPopInteractiveTransition.h"
@implementation KYPopInteractiveTransition{
UIViewController *presentedVC;
}
-(void)addPopGesture:(UIViewController *)viewController{
presentedVC = viewController;
UIScreenEdgePanGestureRecognizer *edgeGes = [[UIScreenEdgePanGestureRecognizer alloc]initWithTarget:self action:@selector(edgeGesPan:)];
edgeGes.edges = UIRectEdgeLeft;
[viewController.view addGestureRecognizer:edgeGes];
}
-(void)edgeGesPan:(UIScreenEdgePanGestureRecognizer *)edgeGes{
CGFloat translation =[edgeGes translationInView:presentedVC.view].x;
CGFloat percent = translation / (presentedVC.view.bounds.size.width/2);
percent = MIN(0.99, MAX(0.0, percent));
NSLog(@"%f",percent);
switch (edgeGes.state) {
case UIGestureRecognizerStateBegan:{
self.interacting = YES;
// [presentedVC dismissViewControllerAnimated:YES completion:nil];
// navigationController
[presentedVC.navigationController popViewControllerAnimated:YES];
break;
}
case UIGestureRecognizerStateChanged:{
[self updateInteractiveTransition:percent];
break;
}
case UIGestureRecognizerStateEnded:{
self.interacting = NO;
if (percent > 0.5) {
[self finishInteractiveTransition];
}else{
[self cancelInteractiveTransition];
}
break;
}
default:
break;
}
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPopInteractiveTransition.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 344 |
```objective-c
//
// YFPushTransitionViewController.m
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import "YFPushTransitionViewController.h"
#import "YFSecondPushViewController.h"
#import "KYPushTransition.h"
#import "KYPopTransition.h"
#import "KYPopInteractiveTransition.h"
@interface YFPushTransitionViewController (){
KYPopInteractiveTransition *popInteractive;
}
@end
@implementation YFPushTransitionViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
UIButton *nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[nextBtn setTitle:@"" forState:UIControlStateNormal];
nextBtn.backgroundColor = [UIColor redColor];
[nextBtn addTarget:self action:@selector(text) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:nextBtn];
self.navigationController.delegate = self;
}
- (void)text {
YFSecondPushViewController *secondVC = [[YFSecondPushViewController alloc] init];
self.transitioningDelegate = self;
popInteractive = [KYPopInteractiveTransition new];
[popInteractive addPopGesture:secondVC];
[self.navigationController pushViewController:secondVC animated:YES];
}
#pragma mark -- UINavigationController VC
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC{
if (operation == UINavigationControllerOperationPush) {
KYPushTransition *flip = [KYPushTransition new];
return flip;
}else if (operation == UINavigationControllerOperationPop){
KYPopTransition *flip = [KYPopTransition new];
return flip;
}else{
return nil;
}
}
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController{
return popInteractive.interacting ? popInteractive : nil;
}
//#pragma mark -- VCpresentdismiss
//- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
//
// KYPushTransition *flip = [KYPushTransition new];
//
// return flip;
//}
//
//- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
// KYPopTransition *flip = [KYPopTransition new];
// return flip;
//
//}
//
//
//- (id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator{
// return popInteractive.interacting ? popInteractive : nil;
//
//}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/YFPushTransitionViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 604 |
```objective-c
//
// KYPushTransition.h
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/18/15.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface KYPushTransition : NSObject<UIViewControllerAnimatedTransitioning>
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPushTransition.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 62 |
```objective-c
//
// KYPushTransition.m
// KYPushTransitionDemo
//
// Created by Kitten Yang on 4/18/15.
//
#import "YFPushTransitionViewController.h"
#import "YFSecondPushViewController.h"
#import "KYPushTransition.h"
@interface KYPushTransition()
@property (nonatomic,strong)id<UIViewControllerContextTransitioning> transitionContext;
@end
@implementation KYPushTransition
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext{
return 0.6f;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext{
//toViewcontainerView
YFPushTransitionViewController *fromVC = (YFPushTransitionViewController *)[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
YFSecondPushViewController *toVC = (YFSecondPushViewController *)[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *fromView = fromVC.view;
UIView *toView = toVC.view;
UIView *containerView = [transitionContext containerView];
[containerView addSubview:toView];
[containerView sendSubviewToBack:toView];
//transform
CATransform3D transform = CATransform3DIdentity;
transform.m34 = -0.002;
containerView.layer.sublayerTransform = transform;
//fromVCtoVCframe
CGRect initialFrame = [transitionContext initialFrameForViewController:fromVC];
fromView.frame = initialFrame;
toView.frame = initialFrame;
[self updateAnchorPointAndOffset:CGPointMake(0.0, 0.5) view:fromView];
//
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = fromView.bounds;
gradient.colors = @[(id)[UIColor colorWithWhite:0.0 alpha:0.5].CGColor,
(id)[UIColor colorWithWhite:0.0 alpha:0.0].CGColor];
gradient.startPoint = CGPointMake(0.0, 0.5);
gradient.endPoint = CGPointMake(0.8, 0.5);
UIView *shadow = [[UIView alloc]initWithFrame:fromView.bounds];
shadow.backgroundColor = [UIColor clearColor];
[shadow.layer insertSublayer:gradient atIndex:1];
shadow.alpha = 0.0;
[fromView addSubview:shadow];
[UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
//fromView 90
fromView.layer.transform = CATransform3DMakeRotation(-M_PI_2, 0, 1.0, 0);
shadow.alpha = 1.0;
} completion:^(BOOL finished) {
fromView.layer.anchorPoint = CGPointMake(0.5, 0.5);
fromView.layer.position = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds));
fromView.layer.transform = CATransform3DIdentity;
[shadow removeFromSuperview];
[transitionContext completeTransition:YES];
}];
}
//View
-(void)updateAnchorPointAndOffset:(CGPoint)anchorPoint view:(UIView *)view{
view.layer.anchorPoint = anchorPoint;
view.layer.position = CGPointMake(0, CGRectGetMidY([UIScreen mainScreen].bounds));
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/KYPushTransition.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 725 |
```objective-c
//
// YFSecondPushViewController.h
// BigShow1949
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFSecondPushViewController : UIViewController<UIViewControllerTransitioningDelegate>
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/核心动画/3D翻转push跳转/YFSecondPushViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 57 |
```objective-c
//
// YFNormalAnimationsViewController.m
// appStoreDemo
//
// Created by zhht01 on 16/1/22.
//
#import "YFNormalAnimationsViewController.h"
#import "DeformationButton.h"
@interface YFNormalAnimationsViewController (){
DeformationButton *deformationBtn;
}
@end
@implementation YFNormalAnimationsViewController
- (UIColor *)getColor:(NSString *)hexColor
{
unsigned int red,green,blue;
NSRange range;
range.length = 2;
range.location = 0;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
range.location = 2;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
range.location = 4;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green / 255.0f) blue:(float)(blue / 255.0f) alpha:1.0f];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
deformationBtn = [[DeformationButton alloc]initWithFrame:CGRectMake(100, 100, 140, 36)];
deformationBtn.contentColor = [self getColor:@"52c332"];
deformationBtn.progressColor = [UIColor whiteColor];
[self.view addSubview:deformationBtn];
[deformationBtn.forDisplayButton setTitle:@"" forState:UIControlStateNormal];
[deformationBtn.forDisplayButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
[deformationBtn.forDisplayButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[deformationBtn.forDisplayButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 6, 0, 0)];
[deformationBtn.forDisplayButton setImage:[UIImage imageNamed:@"logo_.png"] forState:UIControlStateNormal];
UIImage *bgImage = [UIImage imageNamed:@"button_bg.png"];
[deformationBtn.forDisplayButton setBackgroundImage:[bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
[deformationBtn addTarget:self action:@selector(btnEvent) forControlEvents:UIControlEventTouchUpInside];
}
- (void)btnEvent{
NSLog(@"btnEvent");
}
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/一般动画/YFNormalAnimationsViewController.m | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 499 |
```objective-c
//
// YFNormalAnimationsViewController.h
// appStoreDemo
//
// Created by zhht01 on 16/1/22.
//
#import <UIKit/UIKit.h>
@interface YFNormalAnimationsViewController : UIViewController
@end
``` | /content/code_sandbox/BigShow1949/Classes/07 - Animations(动画)/一般动画/YFNormalAnimationsViewController.h | objective-c | 2016-05-05T08:19:43 | 2024-08-07T09:29:21 | BigShow1949 | BigShow1949/BigShow1949 | 1,121 | 51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.