├── README.md
└── iOS-PHP
├── php.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── lidongxu.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── lidongxu.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── php.xcscheme
│ └── xcschememanagement.plist
├── php
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Info.plist
├── LDXKit
│ ├── Define.h
│ ├── LoginRegisterView
│ │ ├── LoginView.h
│ │ ├── LoginView.m
│ │ ├── RegisterView.h
│ │ └── RegisterView.m
│ ├── NSObject
│ │ ├── LDXNetWork.h
│ │ └── LDXNetWork.m
│ ├── System
│ │ └── SystemInfo.h
│ ├── ThreePart
│ │ ├── AFNetworking3.0
│ │ │ ├── AFNetworking
│ │ │ │ ├── AFHTTPSessionManager.h
│ │ │ │ ├── AFHTTPSessionManager.m
│ │ │ │ ├── AFNetworkReachabilityManager.h
│ │ │ │ ├── AFNetworkReachabilityManager.m
│ │ │ │ ├── AFNetworking.h
│ │ │ │ ├── AFSecurityPolicy.h
│ │ │ │ ├── AFSecurityPolicy.m
│ │ │ │ ├── AFURLRequestSerialization.h
│ │ │ │ ├── AFURLRequestSerialization.m
│ │ │ │ ├── AFURLResponseSerialization.h
│ │ │ │ ├── AFURLResponseSerialization.m
│ │ │ │ ├── AFURLSessionManager.h
│ │ │ │ └── AFURLSessionManager.m
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ └── UIKit+AFNetworking
│ │ │ │ ├── AFAutoPurgingImageCache.h
│ │ │ │ ├── AFAutoPurgingImageCache.m
│ │ │ │ ├── AFImageDownloader.h
│ │ │ │ ├── AFImageDownloader.m
│ │ │ │ ├── AFNetworkActivityIndicatorManager.h
│ │ │ │ ├── AFNetworkActivityIndicatorManager.m
│ │ │ │ ├── UIActivityIndicatorView+AFNetworking.h
│ │ │ │ ├── UIActivityIndicatorView+AFNetworking.m
│ │ │ │ ├── UIButton+AFNetworking.h
│ │ │ │ ├── UIButton+AFNetworking.m
│ │ │ │ ├── UIImage+AFNetworking.h
│ │ │ │ ├── UIImageView+AFNetworking.h
│ │ │ │ ├── UIImageView+AFNetworking.m
│ │ │ │ ├── UIKit+AFNetworking.h
│ │ │ │ ├── UIProgressView+AFNetworking.h
│ │ │ │ ├── UIProgressView+AFNetworking.m
│ │ │ │ ├── UIRefreshControl+AFNetworking.h
│ │ │ │ ├── UIRefreshControl+AFNetworking.m
│ │ │ │ ├── UIWebView+AFNetworking.h
│ │ │ │ └── UIWebView+AFNetworking.m
│ │ └── Masonry
│ │ │ ├── MASCompositeConstraint.h
│ │ │ ├── MASCompositeConstraint.m
│ │ │ ├── MASConstraint+Private.h
│ │ │ ├── MASConstraint.h
│ │ │ ├── MASConstraint.m
│ │ │ ├── MASConstraintMaker.h
│ │ │ ├── MASConstraintMaker.m
│ │ │ ├── MASLayoutConstraint.h
│ │ │ ├── MASLayoutConstraint.m
│ │ │ ├── MASUtilities.h
│ │ │ ├── MASViewAttribute.h
│ │ │ ├── MASViewAttribute.m
│ │ │ ├── MASViewConstraint.h
│ │ │ ├── MASViewConstraint.m
│ │ │ ├── Masonry.h
│ │ │ ├── NSArray+MASAdditions.h
│ │ │ ├── NSArray+MASAdditions.m
│ │ │ ├── NSArray+MASShorthandAdditions.h
│ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h
│ │ │ ├── NSLayoutConstraint+MASDebugAdditions.m
│ │ │ ├── View+MASAdditions.h
│ │ │ ├── View+MASAdditions.m
│ │ │ ├── View+MASShorthandAdditions.h
│ │ │ ├── ViewController+MASAdditions.h
│ │ │ └── ViewController+MASAdditions.m
│ ├── UIView+Category
│ │ ├── UIView+GetViewController.h
│ │ └── UIView+GetViewController.m
│ ├── UIviewController+Category
│ │ ├── UIViewController+AlertVC.h
│ │ └── UIViewController+AlertVC.m
│ └── images
│ │ ├── back.jpg
│ │ ├── login.png
│ │ ├── pass.png
│ │ └── zhenxiang.png
├── MainViewController.h
├── MainViewController.m
├── ViewController.h
├── ViewController.m
├── ceshi
├── hello.jpg
└── main.m
├── phpTests
├── Info.plist
└── phpTests.m
└── phpUITests
├── Info.plist
└── phpUITests.m
/README.md:
--------------------------------------------------------------------------------
1 | # iOS-to-PHP
2 | iOS端利用AFN的Get和Post上传字符串和图片数据到PHP编写的代码的本地服务器中
3 |
4 | PHP端代码详见
5 | https://github.com/lidongxuwork/Register-Login-PHP
6 |
7 | 配置步骤详见
8 | http://www.jianshu.com/p/9fd07b8a7aed/comments/2125845#comment-2125845
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/iOS-PHP/php.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS-PHP/php.xcodeproj/project.xcworkspace/xcuserdata/lidongxu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php.xcodeproj/project.xcworkspace/xcuserdata/lidongxu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOS-PHP/php.xcodeproj/xcuserdata/lidongxu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/iOS-PHP/php.xcodeproj/xcuserdata/lidongxu.xcuserdatad/xcschemes/php.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/iOS-PHP/php.xcodeproj/xcuserdata/lidongxu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | php.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B87696DB1C7EF6F9003DDFF3
16 |
17 | primary
18 |
19 |
20 | B87696F41C7EF6F9003DDFF3
21 |
22 | primary
23 |
24 |
25 | B87696FF1C7EF6F9003DDFF3
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/iOS-PHP/php/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOS-PHP/php/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 | return YES;
22 | }
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
27 | }
28 |
29 | - (void)applicationDidEnterBackground:(UIApplication *)application {
30 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
32 | }
33 |
34 | - (void)applicationWillEnterForeground:(UIApplication *)application {
35 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
36 | }
37 |
38 | - (void)applicationDidBecomeActive:(UIApplication *)application {
39 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
40 | }
41 |
42 | - (void)applicationWillTerminate:(UIApplication *)application {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/iOS-PHP/php/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/iOS-PHP/php/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS-PHP/php/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/iOS-PHP/php/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | NSAppTransportSecurity
40 | NSAllowsArbitraryLoads
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/Define.h:
--------------------------------------------------------------------------------
1 | //
2 | // Define.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | // 系统库
10 | #import
11 |
12 | // 获取系统信息
13 | #import "SystemInfo.h"
14 |
15 | // 第三方库
16 | #import "Masonry.h"
17 | #import "AFNetworking.h"
18 |
19 | // 封装的一些View
20 | #import "LoginView.h"
21 | #import "RegisterView.h"
22 |
23 | // 基于AFNetworking封装的网络请求
24 | #import "LDXNetWork.h"
25 |
26 | // UIView类目
27 | #import "UIView+GetViewController.h"
28 |
29 | // UIViewController类目
30 | #import "UIViewController+AlertVC.h"
31 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/LoginRegisterView/LoginView.h:
--------------------------------------------------------------------------------
1 | //
2 | // LoginRegisterView.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/9.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol LoginRegisterDelegate
12 |
13 | @optional
14 | // 调用这个代理协议获取登录的用户名, 密码
15 | - (void)getLoginName:(NSString *)name
16 | pass:(NSString *)pass;
17 |
18 | // 调用这个代理协议获取注册用的一些信息
19 | - (void)getRegisterName:(NSString *)name
20 | pass:(NSString *)pass
21 | age:(NSString *)age
22 | telephone:(NSString *)telephone
23 | image:(UIImage *)image;
24 |
25 | @end
26 | @interface LoginView : UIView
27 |
28 | @property (nonatomic, strong) UITextField *nameTextF;
29 | @property (nonatomic, strong) UITextField *passWordF;
30 | @property (nonatomic, strong) UIButton *loginButton;
31 | @property (nonatomic, strong) UIButton * registerButton;
32 |
33 | // 登录页面背景图片
34 | @property (nonatomic, strong) UIImage *backImage;
35 |
36 | // 注册成功返回登录页面
37 | - (void)goToLoginView;
38 |
39 | #warning
40 | // 如果要获取登录信息和注册信息, 请签订代理(实现协议方法)
41 | @property (nonatomic, assign) id delegate;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/LoginRegisterView/RegisterView.h:
--------------------------------------------------------------------------------
1 | //
2 | // RegisterView.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RegisterView : UIView
12 |
13 | @property (nonatomic, strong) UIButton *registerButton;
14 | @property (nonatomic, strong) UITextField *nameTextF;
15 | @property (nonatomic, strong) UITextField *passTextF;
16 | @property (nonatomic, strong) UITextField *ageTextF;
17 | @property (nonatomic, strong) UITextField *telephoneF;
18 |
19 | // 返回按钮
20 | @property (nonatomic, strong) UIButton *backButton;
21 |
22 | // 用户头像
23 | @property (nonatomic, strong) UIButton *headerImageButton;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/LoginRegisterView/RegisterView.m:
--------------------------------------------------------------------------------
1 | //
2 | // RegisterView.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "RegisterView.h"
10 | #import "Define.h"
11 |
12 | @interface RegisterView ()
13 |
14 | @end
15 | @implementation RegisterView
16 |
17 | #pragma mark - property
18 | - (UIButton *)backButton
19 | {
20 | if (_backButton == nil) {
21 | self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
22 | _backButton.backgroundColor = [UIColor blackColor];
23 | [_backButton setTitle:@"<" forState:UIControlStateNormal];
24 | _backButton.titleLabel.font = [UIFont systemFontOfSize:25.0f * screenH];
25 | [_backButton addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
26 | [self addSubview:_backButton];
27 | [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
28 | make.top.mas_equalTo(70 * screenH);
29 | make.left.mas_equalTo(0);
30 | make.width.mas_equalTo(30 * screenW);
31 | make.height.mas_equalTo(50 * screenH);
32 | }];
33 | }
34 |
35 | return _backButton;
36 | }
37 |
38 | - (UITextField *)nameTextF
39 | {
40 | if (_nameTextF == nil) {
41 | self.nameTextF = [self textFieldFatory:_nameTextF name:@"请输入用户名"];
42 | [_nameTextF mas_makeConstraints:^(MASConstraintMaker *make) {
43 | make.top.mas_equalTo(70 * screenH);
44 | make.left.mas_equalTo(40 * screenW);
45 | make.right.mas_equalTo(self).offset(-40 * screenW);
46 | make.height.mas_equalTo(50 * screenH);
47 | }];
48 | }
49 | return _nameTextF;
50 | }
51 |
52 | - (UITextField *)passTextF
53 | {
54 | if (_passTextF == nil) {
55 |
56 | self.passTextF = [self textFieldFatory:_passTextF name:@"请输入密码"];
57 | _passTextF.secureTextEntry = YES;
58 | [_passTextF mas_makeConstraints:^(MASConstraintMaker *make) {
59 | make.top.equalTo(self.nameTextF.mas_bottom).offset(20);
60 | make.centerX.equalTo(self.nameTextF.mas_centerX);
61 | make.width.equalTo(self.nameTextF.mas_width);
62 | make.height.equalTo(self.nameTextF.mas_height);
63 | }];
64 | }
65 |
66 | return _passTextF;
67 | }
68 |
69 | - (UITextField *)ageTextF
70 | {
71 | if (_ageTextF == nil) {
72 | self.ageTextF = [self textFieldFatory:_ageTextF name:@"请输入年龄"];
73 | [_ageTextF mas_makeConstraints:^(MASConstraintMaker *make) {
74 | make.top.equalTo(self.passTextF.mas_bottom).offset(20);
75 | make.centerX.equalTo(self.passTextF.mas_centerX);
76 | make.width.equalTo(self.passTextF.mas_width);
77 | make.height.equalTo(self.passTextF.mas_height);
78 | }];
79 | }
80 | return _ageTextF;
81 | }
82 |
83 | - (UITextField *)telephoneF
84 | {
85 | if (_telephoneF == nil) {
86 | self.telephoneF = [self textFieldFatory:_telephoneF name:@"请输入你电话号"];
87 | [_telephoneF mas_makeConstraints:^(MASConstraintMaker *make) {
88 | make.top.equalTo(self.ageTextF.mas_bottom).offset(20);
89 | make.centerX.equalTo(self.ageTextF.mas_centerX);
90 | make.width.equalTo(self.ageTextF.mas_width);
91 | make.height.equalTo(self.ageTextF.mas_height);
92 | }];
93 | }
94 | return _telephoneF;
95 | }
96 |
97 | - (UIButton *)registerButton
98 | {
99 | if (_registerButton == nil) {
100 | self.registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
101 | [self addSubview:_registerButton];
102 | _registerButton.backgroundColor = colorRGBA(105, 243, 20, 0.8);
103 | _registerButton.layer.cornerRadius = 15;
104 | [_registerButton setTitle:@"注 册" forState:UIControlStateNormal];
105 | [_registerButton mas_makeConstraints:^(MASConstraintMaker *make) {
106 | make.top.equalTo(self.telephoneF.mas_bottom).offset(30 * screenH);
107 | make.centerX.equalTo(self.telephoneF.mas_centerX);
108 | make.height.equalTo(self.telephoneF.mas_height);
109 | make.width.equalTo(self.telephoneF.mas_width);
110 | }];
111 | }
112 |
113 | return _registerButton;
114 | }
115 |
116 | - (UIButton *)headerImageButton
117 | {
118 | if (_headerImageButton == nil) {
119 | self.headerImageButton = [UIButton buttonWithType:UIButtonTypeCustom];
120 | [_headerImageButton setImage:[UIImage imageNamed:@"zhenxiang.png"] forState:UIControlStateNormal];
121 | [_headerImageButton addTarget:self action:@selector(selectUserImage) forControlEvents:UIControlEventTouchUpInside];
122 | [self addSubview:_headerImageButton];
123 | [_headerImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
124 | make.top.equalTo(self.registerButton.mas_bottom).offset(50 * screenH);
125 | make.left.mas_equalTo(80 * screenW);
126 | make.right.mas_equalTo(self).offset(-80 * screenW);
127 | make.bottom.equalTo(self).offset(-50 * screenH);
128 | }];
129 | }
130 |
131 | return _headerImageButton;
132 | }
133 |
134 | // 因为本页面textField都差不多, 把公共代码提取出来
135 | - (UITextField *)textFieldFatory:(UITextField *)textField name:(NSString *)placeholder
136 | {
137 | textField = [[UITextField alloc] init];
138 | textField.placeholder = placeholder;
139 | textField.textAlignment = NSTextAlignmentCenter;
140 | textField.backgroundColor = colorRGBA(244, 244, 244, 1);
141 | textField.layer.borderWidth = 1;
142 | textField.layer.cornerRadius = 15;
143 | textField.returnKeyType = UIReturnKeyNext;
144 | [self addSubview:textField];
145 | return textField;
146 | }
147 |
148 |
149 | #pragma mark - init
150 | - (instancetype)init
151 | {
152 | self = [self initWithFrame:CGRectZero];
153 |
154 | return self;
155 | }
156 |
157 | - (instancetype)initWithFrame:(CGRect)frame
158 | {
159 | if (self = [super initWithFrame:frame]) {
160 |
161 | self.backgroundColor = colorRGBA(222, 222, 222, 1);
162 |
163 | // 初始化控件
164 | [self backButton];
165 | [self headerImageButton];
166 |
167 | }
168 |
169 | return self;
170 | }
171 |
172 | #pragma mark - buttonAction
173 | - (void)selectUserImage
174 | {
175 | UIImagePickerController *picker = [[UIImagePickerController alloc] init];
176 | // 从图库来源
177 | picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
178 | picker.allowsEditing = YES;
179 | picker.delegate = self;
180 | UIViewController *theViewController = [self theViewController];
181 | [theViewController presentViewController:picker animated:YES completion:nil];
182 | }
183 |
184 | - (void)backButtonAction
185 | {
186 | // 清空注册登录控件里的数据(防止没注册传递回去)
187 | self.nameTextF.text = @"";
188 | self.passTextF.text = @"";
189 | [UIView animateWithDuration:1.0 animations:^{
190 | self.frame = CGRectMake(-375, 0, 0, 667);
191 | // 延迟2秒删除, 不然没有渐变消失的动画
192 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
193 | [self removeFromSuperview];
194 | });
195 | }];
196 |
197 | }
198 |
199 | #pragma mark - imagepickerControllerDelegate
200 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
201 | {
202 | // 获取图片数据
203 | UIImage *ima = info[UIImagePickerControllerEditedImage];
204 | // 给button按钮改变图片
205 | [self.headerImageButton setImage:ima forState:UIControlStateNormal];
206 | [picker dismissViewControllerAnimated:YES completion:nil];
207 | }
208 |
209 |
210 |
211 |
212 | @end
213 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/NSObject/LDXNetWork.h:
--------------------------------------------------------------------------------
1 | //
2 | // LDXNetWork.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/11.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class UIImage;
12 | @interface LDXNetWork : NSObject
13 |
14 | // 普通版GET网络请求(做登录验证使用)
15 | + (void)GetThePHPWithURL:(NSString *)str par:(NSDictionary *)dic success:(void(^)(id responseObject))response error:(void(^)(NSError *error))err;
16 |
17 | // 做注册POST网路请求
18 | + (void)PostThePHPWithURL:(NSString *)str par:(NSDictionary *)dic image:(UIImage *)image uploadName:(NSString *)uploadName success:(void (^)(id response))response error:(void (^)(NSError *error))err;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/NSObject/LDXNetWork.m:
--------------------------------------------------------------------------------
1 | //
2 | // LDXNetWork.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/11.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "LDXNetWork.h"
10 | #import "Define.h"
11 |
12 | @implementation LDXNetWork
13 |
14 | + (void)GetThePHPWithURL:(NSString *)str par:(NSDictionary *)dic success:(void(^)(id responseObject))response error:(void(^)(NSError *error))err
15 | {
16 |
17 | AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
18 | // 返回二进制格式数据
19 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
20 | // 要写http://
21 | // 把字段写在字典里和放在网址后面? name=lidongxu&pass=123 是一样的
22 | // name 和 pass 是php那面(也就是后台定义的字段要遵守)
23 | [manager GET:str parameters:dic success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
24 | // 这里返回回来的数据不是JSON 是data, 但是不能直接转化成JSON, 而先得转化成字符串
25 | NSString *s = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
26 | NSData *data = [s dataUsingEncoding:NSUTF8StringEncoding];
27 | NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
28 |
29 | response(dic);
30 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
31 | err(error);
32 | }];
33 | }
34 |
35 | + (void)PostThePHPWithURL:(NSString *)str par:(NSDictionary *)dic image:(UIImage *)image uploadName:(NSString *)uploadName success:(void (^)(id))response error:(void (^)(NSError *))err
36 | {
37 | // 3. POST表单上传图片
38 |
39 | AFHTTPSessionManager *man = [AFHTTPSessionManager manager];
40 | man.responseSerializer = [AFHTTPResponseSerializer serializer];
41 | // 要写http://
42 | // 把字段写在字典里和放在网址后面? name=lidongxu&pass=123 是一样的
43 | // name 和 pass 是php那面(也就是后台定义的字段要遵守)
44 |
45 | [man POST:str parameters:dic constructingBodyWithBlock:^(id _Nonnull formData) {
46 |
47 | NSData *data2 = UIImageJPEGRepresentation(image, 1);
48 | // uploadfile是后台定义的
49 | // image/jpeg 代表你上传的是图片
50 | [formData appendPartWithFileData:data2 name:uploadName fileName:@"imgfileStyle.png" mimeType:@"image/jpeg"];
51 |
52 | } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
53 |
54 | // 这里返回回来的数据不是JSON 是data, 但是不能直接转化成JSON, 而先得转化成字符串
55 | NSString *s = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
56 | NSLog(@"%@", s);
57 | NSData *data = [s dataUsingEncoding:NSUTF8StringEncoding];
58 | NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
59 | response(dic);
60 |
61 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
62 | NSLog(@"%@", error);
63 | }];
64 |
65 | }
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/System/SystemInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemInfo.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | // 适配屏幕 (必须在iOS6下使用)
10 | #define screenH [UIScreen mainScreen].bounds.size.height / 667
11 | #define screenW [UIScreen mainScreen].bounds.size.width / 375
12 |
13 | // 获取当前屏幕高度, 宽度
14 | #define screenNowH [UIScreen mainScreen].bounds.size.height
15 | #define screenNowW [UIScreen mainScreen].bounds.size.width
16 |
17 | // 颜色RGB
18 | #define colorRGBA(r, g, b, a) [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:a]
19 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManager.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if !TARGET_OS_WATCH
25 | #import
26 |
27 | #ifndef NS_DESIGNATED_INITIALIZER
28 | #if __has_attribute(objc_designated_initializer)
29 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
30 | #else
31 | #define NS_DESIGNATED_INITIALIZER
32 | #endif
33 | #endif
34 |
35 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
36 | AFNetworkReachabilityStatusUnknown = -1,
37 | AFNetworkReachabilityStatusNotReachable = 0,
38 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
39 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
40 | };
41 |
42 | NS_ASSUME_NONNULL_BEGIN
43 |
44 | /**
45 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
46 |
47 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
48 |
49 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/)
50 |
51 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
52 | */
53 | @interface AFNetworkReachabilityManager : NSObject
54 |
55 | /**
56 | The current network reachability status.
57 | */
58 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
59 |
60 | /**
61 | Whether or not the network is currently reachable.
62 | */
63 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
64 |
65 | /**
66 | Whether or not the network is currently reachable via WWAN.
67 | */
68 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
69 |
70 | /**
71 | Whether or not the network is currently reachable via WiFi.
72 | */
73 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
74 |
75 | ///---------------------
76 | /// @name Initialization
77 | ///---------------------
78 |
79 | /**
80 | Returns the shared network reachability manager.
81 | */
82 | + (instancetype)sharedManager;
83 |
84 | /**
85 | Creates and returns a network reachability manager with the default socket address.
86 |
87 | @return An initialized network reachability manager, actively monitoring the default socket address.
88 | */
89 | + (instancetype)manager;
90 |
91 | /**
92 | Creates and returns a network reachability manager for the specified domain.
93 |
94 | @param domain The domain used to evaluate network reachability.
95 |
96 | @return An initialized network reachability manager, actively monitoring the specified domain.
97 | */
98 | + (instancetype)managerForDomain:(NSString *)domain;
99 |
100 | /**
101 | Creates and returns a network reachability manager for the socket address.
102 |
103 | @param address The socket address (`sockaddr_in`) used to evaluate network reachability.
104 |
105 | @return An initialized network reachability manager, actively monitoring the specified socket address.
106 | */
107 | + (instancetype)managerForAddress:(const void *)address;
108 |
109 | /**
110 | Initializes an instance of a network reachability manager from the specified reachability object.
111 |
112 | @param reachability The reachability object to monitor.
113 |
114 | @return An initialized network reachability manager, actively monitoring the specified reachability.
115 | */
116 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
117 |
118 | ///--------------------------------------------------
119 | /// @name Starting & Stopping Reachability Monitoring
120 | ///--------------------------------------------------
121 |
122 | /**
123 | Starts monitoring for changes in network reachability status.
124 | */
125 | - (void)startMonitoring;
126 |
127 | /**
128 | Stops monitoring for changes in network reachability status.
129 | */
130 | - (void)stopMonitoring;
131 |
132 | ///-------------------------------------------------
133 | /// @name Getting Localized Reachability Description
134 | ///-------------------------------------------------
135 |
136 | /**
137 | Returns a localized string representation of the current network reachability status.
138 | */
139 | - (NSString *)localizedNetworkReachabilityStatusString;
140 |
141 | ///---------------------------------------------------
142 | /// @name Setting Network Reachability Change Callback
143 | ///---------------------------------------------------
144 |
145 | /**
146 | Sets a callback to be executed when the network availability of the `baseURL` host changes.
147 |
148 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
149 | */
150 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
151 |
152 | @end
153 |
154 | ///----------------
155 | /// @name Constants
156 | ///----------------
157 |
158 | /**
159 | ## Network Reachability
160 |
161 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
162 |
163 | enum {
164 | AFNetworkReachabilityStatusUnknown,
165 | AFNetworkReachabilityStatusNotReachable,
166 | AFNetworkReachabilityStatusReachableViaWWAN,
167 | AFNetworkReachabilityStatusReachableViaWiFi,
168 | }
169 |
170 | `AFNetworkReachabilityStatusUnknown`
171 | The `baseURL` host reachability is not known.
172 |
173 | `AFNetworkReachabilityStatusNotReachable`
174 | The `baseURL` host cannot be reached.
175 |
176 | `AFNetworkReachabilityStatusReachableViaWWAN`
177 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
178 |
179 | `AFNetworkReachabilityStatusReachableViaWiFi`
180 | The `baseURL` host can be reached via a Wi-Fi connection.
181 |
182 | ### Keys for Notification UserInfo Dictionary
183 |
184 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
185 |
186 | `AFNetworkingReachabilityNotificationStatusItem`
187 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
188 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
189 | */
190 |
191 | ///--------------------
192 | /// @name Notifications
193 | ///--------------------
194 |
195 | /**
196 | Posted when network reachability changes.
197 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
198 |
199 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`).
200 | */
201 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
202 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
203 |
204 | ///--------------------
205 | /// @name Functions
206 | ///--------------------
207 |
208 | /**
209 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
210 | */
211 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
212 |
213 | NS_ASSUME_NONNULL_END
214 | #endif
215 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import
25 | #import
26 |
27 | #ifndef _AFNETWORKING_
28 | #define _AFNETWORKING_
29 |
30 | #import "AFURLRequestSerialization.h"
31 | #import "AFURLResponseSerialization.h"
32 | #import "AFSecurityPolicy.h"
33 |
34 | #if !TARGET_OS_WATCH
35 | #import "AFNetworkReachabilityManager.h"
36 | #endif
37 |
38 | #import "AFURLSessionManager.h"
39 | #import "AFHTTPSessionManager.h"
40 |
41 | #endif /* _AFNETWORKING_ */
42 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | // AFSecurityPolicy.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
26 | AFSSLPinningModeNone,
27 | AFSSLPinningModePublicKey,
28 | AFSSLPinningModeCertificate,
29 | };
30 |
31 | /**
32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
33 |
34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
35 | */
36 |
37 | NS_ASSUME_NONNULL_BEGIN
38 |
39 | @interface AFSecurityPolicy : NSObject
40 |
41 | /**
42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
43 | */
44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
45 |
46 | /**
47 | The certificates used to evaluate server trust according to the SSL pinning mode.
48 |
49 | By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
50 |
51 | Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
52 | */
53 | @property (nonatomic, strong, nullable) NSArray *pinnedCertificates;
54 |
55 | /**
56 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
57 | */
58 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
59 |
60 | /**
61 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
62 | */
63 | @property (nonatomic, assign) BOOL validatesDomainName;
64 |
65 | ///-----------------------------------------
66 | /// @name Getting Certificates from the Bundle
67 | ///-----------------------------------------
68 |
69 | /**
70 | Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
71 |
72 | @return The default security policy.
73 | */
74 | + (NSArray *)certificatesInBundle:(NSBundle *)bundle;
75 |
76 | ///-----------------------------------------
77 | /// @name Getting Specific Security Policies
78 | ///-----------------------------------------
79 |
80 | /**
81 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
82 |
83 | @return The default security policy.
84 | */
85 | + (instancetype)defaultPolicy;
86 |
87 | ///---------------------
88 | /// @name Initialization
89 | ///---------------------
90 |
91 | /**
92 | Creates and returns a security policy with the specified pinning mode.
93 |
94 | @param pinningMode The SSL pinning mode.
95 |
96 | @return A new security policy.
97 | */
98 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
99 |
100 | /**
101 | Creates and returns a security policy with the specified pinning mode.
102 |
103 | @param pinningMode The SSL pinning mode.
104 | @param pinnedCertificates The certificates to pin against.
105 |
106 | @return A new security policy.
107 | */
108 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSArray *)pinnedCertificates;
109 |
110 | ///------------------------------
111 | /// @name Evaluating Server Trust
112 | ///------------------------------
113 |
114 | /**
115 | Whether or not the specified server trust should be accepted, based on the security policy.
116 |
117 | This method should be used when responding to an authentication challenge from a server.
118 |
119 | @param serverTrust The X.509 certificate trust of the server.
120 |
121 | @return Whether or not to trust the server.
122 |
123 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`.
124 | */
125 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE;
126 |
127 | /**
128 | Whether or not the specified server trust should be accepted, based on the security policy.
129 |
130 | This method should be used when responding to an authentication challenge from a server.
131 |
132 | @param serverTrust The X.509 certificate trust of the server.
133 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
134 |
135 | @return Whether or not to trust the server.
136 | */
137 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
138 | forDomain:(nullable NSString *)domain;
139 |
140 | @end
141 |
142 | NS_ASSUME_NONNULL_END
143 |
144 | ///----------------
145 | /// @name Constants
146 | ///----------------
147 |
148 | /**
149 | ## SSL Pinning Modes
150 |
151 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
152 |
153 | enum {
154 | AFSSLPinningModeNone,
155 | AFSSLPinningModePublicKey,
156 | AFSSLPinningModeCertificate,
157 | }
158 |
159 | `AFSSLPinningModeNone`
160 | Do not used pinned certificates to validate servers.
161 |
162 | `AFSSLPinningModePublicKey`
163 | Validate host certificates against public keys of pinned certificates.
164 |
165 | `AFSSLPinningModeCertificate`
166 | Validate host certificates against pinned certificates.
167 | */
168 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/AFAutoPurgingImageCache.h:
--------------------------------------------------------------------------------
1 | // AFAutoPurgingImageCache.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 | #import
27 |
28 | NS_ASSUME_NONNULL_BEGIN
29 |
30 | /**
31 | The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
32 | */
33 | @protocol AFImageCache
34 |
35 | /**
36 | Adds the image to the cache with the given identifier.
37 |
38 | @param image The image to cache.
39 | @param identifier The unique identifier for the image in the cache.
40 | */
41 | - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
42 |
43 | /**
44 | Removes the image from the cache matching the given identifier.
45 |
46 | @param identifier The unique identifier for the image in the cache.
47 |
48 | @return A BOOL indicating whether or not the image was removed from the cache.
49 | */
50 | - (BOOL)removeImageWithIdentifier:(NSString *)identifier;
51 |
52 | /**
53 | Removes all images from the cache.
54 |
55 | @return A BOOL indicating whether or not all images were removed from the cache.
56 | */
57 | - (BOOL)removeAllImages;
58 |
59 | /**
60 | Returns the image in the cache associated with the given identifier.
61 |
62 | @param identifier The unique identifier for the image in the cache.
63 |
64 | @return An image for the matching identifier, or nil.
65 | */
66 | - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
67 | @end
68 |
69 |
70 | /**
71 | The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier.
72 | */
73 | @protocol AFImageRequestCache
74 |
75 | /**
76 | Adds the image to the cache using an identifier created from the request and additional identifier.
77 |
78 | @param image The image to cache.
79 | @param request The unique URL request identifing the image asset.
80 | @param identifier The additional identifier to apply to the URL request to identify the image.
81 | */
82 | - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
83 |
84 | /**
85 | Removes the image from the cache using an identifier created from the request and additional identifier.
86 |
87 | @param request The unique URL request identifing the image asset.
88 | @param identifier The additional identifier to apply to the URL request to identify the image.
89 |
90 | @return A BOOL indicating whether or not all images were removed from the cache.
91 | */
92 | - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
93 |
94 | /**
95 | Returns the image from the cache associated with an identifier created from the request and additional identifier.
96 |
97 | @param request The unique URL request identifing the image asset.
98 | @param identifier The additional identifier to apply to the URL request to identify the image.
99 |
100 | @return An image for the matching request and identifier, or nil.
101 | */
102 | - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
103 |
104 | @end
105 |
106 | /**
107 | The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.
108 | */
109 | @interface AFAutoPurgingImageCache : NSObject
110 |
111 | /**
112 | The total memory capacity of the cache in bytes.
113 | */
114 | @property (nonatomic, assign) UInt64 memoryCapacity;
115 |
116 | /**
117 | The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
118 | */
119 | @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
120 |
121 | /**
122 | The current total memory usage in bytes of all images stored within the cache.
123 | */
124 | @property (nonatomic, assign, readonly) UInt64 memoryUsage;
125 |
126 | /**
127 | Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`.
128 |
129 | @return The new `AutoPurgingImageCache` instance.
130 | */
131 | - (instancetype)init;
132 |
133 | /**
134 | Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
135 | after purge limit.
136 |
137 | @param memoryCapacity The total memory capacity of the cache in bytes.
138 | @param preferredMemoryUsageAfterPurge The preferred memory usage after purge in bytes.
139 |
140 | @return The new `AutoPurgingImageCache` instance.
141 | */
142 | - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
143 |
144 | @end
145 |
146 | NS_ASSUME_NONNULL_END
147 |
148 | #endif
149 |
150 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/AFAutoPurgingImageCache.m:
--------------------------------------------------------------------------------
1 | // AFAutoPurgingImageCache.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if TARGET_OS_IOS || TARGET_OS_TV
25 |
26 | #import "AFAutoPurgingImageCache.h"
27 |
28 | @interface AFCachedImage : NSObject
29 |
30 | @property (nonatomic, strong) UIImage *image;
31 | @property (nonatomic, strong) NSString *identifier;
32 | @property (nonatomic, assign) UInt64 totalBytes;
33 | @property (nonatomic, strong) NSDate *lastAccessDate;
34 | @property (nonatomic, assign) UInt64 currentMemoryUsage;
35 |
36 | @end
37 |
38 | @implementation AFCachedImage
39 |
40 | -(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
41 | if (self = [self init]) {
42 | self.image = image;
43 | self.identifier = identifier;
44 |
45 | CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale);
46 | CGFloat bytesPerPixel = 4.0;
47 | CGFloat bytesPerRow = imageSize.width * bytesPerPixel;
48 | self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerRow;
49 | self.lastAccessDate = [NSDate date];
50 | }
51 | return self;
52 | }
53 |
54 | - (UIImage*)accessImage {
55 | self.lastAccessDate = [NSDate date];
56 | return self.image;
57 | }
58 |
59 | - (NSString *)description {
60 | NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate];
61 | return descriptionString;
62 |
63 | }
64 |
65 | @end
66 |
67 | @interface AFAutoPurgingImageCache ()
68 | @property (nonatomic, strong) NSMutableDictionary *cachedImages;
69 | @property (nonatomic, assign) UInt64 currentMemoryUsage;
70 | #if OS_OBJECT_HAVE_OBJC_SUPPORT
71 | @property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
72 | #else
73 | @property (nonatomic, assign) dispatch_queue_t synchronizationQueue;
74 | #endif
75 | @end
76 |
77 | @implementation AFAutoPurgingImageCache
78 |
79 | - (instancetype)init {
80 | return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024];
81 | }
82 |
83 | - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity {
84 | if (self = [super init]) {
85 | self.memoryCapacity = memoryCapacity;
86 | self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity;
87 | self.cachedImages = [[NSMutableDictionary alloc] init];
88 |
89 | NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]];
90 | self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
91 |
92 | [[NSNotificationCenter defaultCenter]
93 | addObserver:self
94 | selector:@selector(removeAllImages)
95 | name:UIApplicationDidReceiveMemoryWarningNotification
96 | object:nil];
97 |
98 | }
99 | return self;
100 | }
101 |
102 | - (void)dealloc {
103 | [[NSNotificationCenter defaultCenter] removeObserver:self];
104 | }
105 |
106 | - (UInt64)memoryUsage {
107 | __block UInt64 result = 0;
108 | dispatch_sync(self.synchronizationQueue, ^{
109 | result = self.currentMemoryUsage;
110 | });
111 | return result;
112 | }
113 |
114 | - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
115 | dispatch_barrier_async(self.synchronizationQueue, ^{
116 | AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier];
117 |
118 | AFCachedImage *previousCachedImage = self.cachedImages[identifier];
119 | if (previousCachedImage != nil) {
120 | self.currentMemoryUsage -= previousCachedImage.totalBytes;
121 | }
122 |
123 | self.cachedImages[identifier] = cacheImage;
124 | self.currentMemoryUsage += cacheImage.totalBytes;
125 | });
126 |
127 | dispatch_barrier_async(self.synchronizationQueue, ^{
128 | if (self.currentMemoryUsage > self.memoryCapacity) {
129 | UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge;
130 | NSMutableArray *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues];
131 | NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate"
132 | ascending:YES];
133 | [sortedImages sortUsingDescriptors:@[sortDescriptor]];
134 |
135 | UInt64 bytesPurged = 0;
136 |
137 | for (AFCachedImage *cachedImage in sortedImages) {
138 | [self.cachedImages removeObjectForKey:cachedImage.identifier];
139 | bytesPurged += cachedImage.totalBytes;
140 | if (bytesPurged >= bytesToPurge) {
141 | break ;
142 | }
143 | }
144 | self.currentMemoryUsage -= bytesPurged;
145 | }
146 | });
147 | }
148 |
149 | - (BOOL)removeImageWithIdentifier:(NSString *)identifier {
150 | __block BOOL removed = NO;
151 | dispatch_barrier_sync(self.synchronizationQueue, ^{
152 | AFCachedImage *cachedImage = self.cachedImages[identifier];
153 | if (cachedImage != nil) {
154 | [self.cachedImages removeObjectForKey:identifier];
155 | self.currentMemoryUsage -= cachedImage.totalBytes;
156 | removed = YES;
157 | }
158 | });
159 | return removed;
160 | }
161 |
162 | - (BOOL)removeAllImages {
163 | __block BOOL removed = NO;
164 | dispatch_barrier_sync(self.synchronizationQueue, ^{
165 | if (self.cachedImages.count > 0) {
166 | [self.cachedImages removeAllObjects];
167 | self.currentMemoryUsage = 0;
168 | removed = YES;
169 | }
170 | });
171 | return removed;
172 | }
173 |
174 | - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier {
175 | __block UIImage *image = nil;
176 | dispatch_sync(self.synchronizationQueue, ^{
177 | AFCachedImage *cachedImage = self.cachedImages[identifier];
178 | image = [cachedImage accessImage];
179 | });
180 | return image;
181 | }
182 |
183 | - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
184 | [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
185 | }
186 |
187 | - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
188 | return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
189 | }
190 |
191 | - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
192 | return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
193 | }
194 |
195 | - (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier {
196 | NSString *key = request.URL.absoluteString;
197 | if (additionalIdentifier != nil) {
198 | key = [key stringByAppendingString:additionalIdentifier];
199 | }
200 | return key;
201 | }
202 |
203 | @end
204 |
205 | #endif
206 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/AFImageDownloader.h:
--------------------------------------------------------------------------------
1 | // AFImageDownloader.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if TARGET_OS_IOS || TARGET_OS_TV
25 |
26 | #import
27 | #import "AFAutoPurgingImageCache.h"
28 | #import "AFHTTPSessionManager.h"
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
33 | AFImageDownloadPrioritizationFIFO,
34 | AFImageDownloadPrioritizationLIFO
35 | };
36 |
37 | /**
38 | The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads.
39 | */
40 | @interface AFImageDownloadReceipt : NSObject
41 |
42 | /**
43 | The data task created by the `AFImageDownloader`.
44 | */
45 | @property (nonatomic, strong) NSURLSessionDataTask *task;
46 |
47 | /**
48 | The unique identifier for the success and failure blocks when duplicate requests are made.
49 | */
50 | @property (nonatomic, strong) NSUUID *receiptID;
51 | @end
52 |
53 | /** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.
54 | */
55 | @interface AFImageDownloader : NSObject
56 |
57 | /**
58 | The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
59 | */
60 | @property (nonatomic, strong, nullable) id imageCache;
61 |
62 | /**
63 | The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
64 | */
65 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
66 |
67 | /**
68 | Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
69 | */
70 | @property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton;
71 |
72 | /**
73 | The shared default instance of `AFImageDownloader` initialized with default values.
74 | */
75 | + (instancetype)defaultInstance;
76 |
77 | /**
78 | Creates a default `NSURLCache` with common usage parameter values.
79 |
80 | @returns The default `NSURLCache` instance.
81 | */
82 | + (NSURLCache *)defaultURLCache;
83 |
84 | /**
85 | Default initializer
86 |
87 | @return An instance of `AFImageDownloader` initialized with default values.
88 | */
89 | - (instancetype)init;
90 |
91 | /**
92 | Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
93 |
94 | @param sessionManager The session manager to use to download images
95 | @param downloadPrioritization The download prioritization of the download queue.
96 | @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`.
97 | @param imageCache The image cache used to store all downloaded images in.
98 |
99 | @return The new `AFImageDownloader` instance.
100 | */
101 | - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
102 | downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
103 | maximumActiveDownloads:(NSInteger)maximumActiveDownloads
104 | imageCache:(nullable id )imageCache;
105 |
106 | /**
107 | Creates a data task using the `sessionManager` instance for the specified URL request.
108 |
109 | If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
110 | appended to the already existing task. Once the task completes, all success or failure blocks attached to the
111 | task are executed in the order they were added.
112 |
113 | @param request The URL request.
114 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
115 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
116 |
117 | @return The image download receipt for the data task if available. `nil` if the image is stored in the image
118 | cache and the URL request cache policy allows the cache to be used.
119 | */
120 | - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
121 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
122 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
123 |
124 | /**
125 | Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
126 |
127 | If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.
128 |
129 | @param imageDownloadReceipt The image download receipt to cancel.
130 | */
131 | - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
132 |
133 | @end
134 |
135 | #endif
136 |
137 | NS_ASSUME_NONNULL_END
138 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | /**
33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
34 |
35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
36 |
37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
38 |
39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
40 |
41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
43 | */
44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
45 | @interface AFNetworkActivityIndicatorManager : NSObject
46 |
47 | /**
48 | A Boolean value indicating whether the manager is enabled.
49 |
50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
51 | */
52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
53 |
54 | /**
55 | A Boolean value indicating whether the network activity indicator manager is currently active.
56 | */
57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
58 |
59 | /**
60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds.
61 |
62 | Apple's HIG describes the following:
63 |
64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence.
65 |
66 | */
67 | @property (nonatomic, assign) NSTimeInterval activationDelay;
68 |
69 | /**
70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds.
71 | */
72 |
73 | @property (nonatomic, assign) NSTimeInterval completionDelay;
74 |
75 | /**
76 | Returns the shared network activity indicator manager object for the system.
77 |
78 | @return The systemwide network activity indicator manager.
79 | */
80 | + (instancetype)sharedManager;
81 |
82 | /**
83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
84 | */
85 | - (void)incrementActivityCount;
86 |
87 | /**
88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
89 | */
90 | - (void)decrementActivityCount;
91 |
92 | /**
93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward.
94 |
95 | @param block A block to be executed when the network activity indicator status changes.
96 | */
97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block;
98 |
99 | @end
100 |
101 | NS_ASSUME_NONNULL_END
102 |
103 | #endif
104 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | /**
31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.
32 | */
33 | @interface UIActivityIndicatorView (AFNetworking)
34 |
35 | ///----------------------------------
36 | /// @name Animating for Session Tasks
37 | ///----------------------------------
38 |
39 | /**
40 | Binds the animating state to the state of the specified task.
41 |
42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
43 | */
44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
45 |
46 | @end
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIActivityIndicatorView+AFNetworking.h"
23 | #import
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 |
27 | #import "AFURLSessionManager.h"
28 |
29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject
30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView;
32 |
33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
34 |
35 | @end
36 |
37 | @implementation UIActivityIndicatorView (AFNetworking)
38 |
39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver {
40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
41 | if (notificationObserver == nil) {
42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self];
43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 | }
45 | return notificationObserver;
46 | }
47 |
48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task];
50 | }
51 |
52 | @end
53 |
54 | @implementation AFActivityIndicatorViewNotificationObserver
55 |
56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView
57 | {
58 | self = [super init];
59 | if (self) {
60 | _activityIndicatorView = activityIndicatorView;
61 | }
62 | return self;
63 | }
64 |
65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
67 |
68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
71 |
72 | if (task) {
73 | if (task.state != NSURLSessionTaskStateCompleted) {
74 |
75 | #pragma clang diagnostic push
76 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
77 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
78 | if (task.state == NSURLSessionTaskStateRunning) {
79 | [self.activityIndicatorView startAnimating];
80 | } else {
81 | [self.activityIndicatorView stopAnimating];
82 | }
83 | #pragma clang diagnostic pop
84 |
85 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
86 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
87 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
88 | }
89 | }
90 | }
91 |
92 | #pragma mark -
93 |
94 | - (void)af_startAnimating {
95 | dispatch_async(dispatch_get_main_queue(), ^{
96 | #pragma clang diagnostic push
97 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
98 | [self.activityIndicatorView startAnimating];
99 | #pragma clang diagnostic pop
100 | });
101 | }
102 |
103 | - (void)af_stopAnimating {
104 | dispatch_async(dispatch_get_main_queue(), ^{
105 | #pragma clang diagnostic push
106 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
107 | [self.activityIndicatorView stopAnimating];
108 | #pragma clang diagnostic pop
109 | });
110 | }
111 |
112 | #pragma mark -
113 |
114 | - (void)dealloc {
115 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
116 |
117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
118 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
119 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
120 | }
121 |
122 | @end
123 |
124 | #endif
125 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIImage+AFNetworking.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+AFNetworking.h
3 | //
4 | //
5 | // Created by Paulo Ferreira on 08/07/15.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 |
27 | #import
28 |
29 | @interface UIImage (AFNetworking)
30 |
31 | + (UIImage*) safeImageWithData:(NSData*)data;
32 |
33 | @end
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFImageDownloader;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
36 | */
37 | @interface UIImageView (AFNetworking)
38 |
39 | ///------------------------------------
40 | /// @name Accessing the Image Downloader
41 | ///------------------------------------
42 |
43 | /**
44 | Set the shared image downloader used to download images.
45 |
46 | @param imageDownloader The shared image downloader used to download images.
47 | */
48 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
49 |
50 | /**
51 | The shared image downloader used to download images.
52 | */
53 | + (AFImageDownloader *)sharedImageDownloader;
54 |
55 | ///--------------------
56 | /// @name Setting Image
57 | ///--------------------
58 |
59 | /**
60 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
61 |
62 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
63 |
64 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
65 |
66 | @param url The URL used for the image request.
67 | */
68 | - (void)setImageWithURL:(NSURL *)url;
69 |
70 | /**
71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
72 |
73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
74 |
75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
76 |
77 | @param url The URL used for the image request.
78 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
79 | */
80 | - (void)setImageWithURL:(NSURL *)url
81 | placeholderImage:(nullable UIImage *)placeholderImage;
82 |
83 | /**
84 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
85 |
86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
87 |
88 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
89 |
90 | @param urlRequest The URL request used for the image request.
91 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
92 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
93 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
94 | */
95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
96 | placeholderImage:(nullable UIImage *)placeholderImage
97 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
98 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
99 |
100 | /**
101 | Cancels any executing image operation for the receiver, if one exists.
102 | */
103 | - (void)cancelImageDownloadTask;
104 |
105 | @end
106 |
107 | NS_ASSUME_NONNULL_END
108 |
109 | #endif
110 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIImageView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIImageView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import "AFImageDownloader.h"
29 |
30 | @interface UIImageView (_AFNetworking)
31 | @property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt;
32 | @end
33 |
34 | @implementation UIImageView (_AFNetworking)
35 |
36 | - (AFImageDownloadReceipt *)af_activeImageDownloadReceipt {
37 | return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt));
38 | }
39 |
40 | - (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
41 | objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
42 | }
43 |
44 | @end
45 |
46 | #pragma mark -
47 |
48 | @implementation UIImageView (AFNetworking)
49 |
50 | + (AFImageDownloader *)sharedImageDownloader {
51 |
52 | #pragma clang diagnostic push
53 | #pragma clang diagnostic ignored "-Wgnu"
54 | return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
55 | #pragma clang diagnostic pop
56 | }
57 |
58 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
59 | objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
60 | }
61 |
62 | #pragma mark -
63 |
64 | - (void)setImageWithURL:(NSURL *)url {
65 | [self setImageWithURL:url placeholderImage:nil];
66 | }
67 |
68 | - (void)setImageWithURL:(NSURL *)url
69 | placeholderImage:(UIImage *)placeholderImage
70 | {
71 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
72 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
73 |
74 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
75 | }
76 |
77 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
78 | placeholderImage:(UIImage *)placeholderImage
79 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
80 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
81 | {
82 |
83 | if ([urlRequest URL] == nil) {
84 | [self cancelImageDownloadTask];
85 | self.image = placeholderImage;
86 | return;
87 | }
88 |
89 | if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
90 | return;
91 | }
92 |
93 | [self cancelImageDownloadTask];
94 |
95 | AFImageDownloader *downloader = [[self class] sharedImageDownloader];
96 | id imageCache = downloader.imageCache;
97 |
98 | //Use the image from the image cache if it exists
99 | UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
100 | if (cachedImage) {
101 | if (success) {
102 | success(urlRequest, nil, cachedImage);
103 | } else {
104 | self.image = cachedImage;
105 | }
106 | self.af_activeImageDownloadReceipt = nil;
107 | } else {
108 | if (placeholderImage) {
109 | self.image = placeholderImage;
110 | }
111 |
112 | __weak __typeof(self)weakSelf = self;
113 | AFImageDownloadReceipt *receipt;
114 | receipt = [downloader
115 | downloadImageForURLRequest:urlRequest
116 | success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
117 | __strong __typeof(weakSelf)strongSelf = weakSelf;
118 | if ([strongSelf isActiveTaskURLEqualToURLRequest:request]) {
119 | if (success) {
120 | success(request, response, responseObject);
121 | } else if(responseObject) {
122 | strongSelf.image = responseObject;
123 | }
124 | strongSelf.af_activeImageDownloadReceipt = nil;
125 | }
126 |
127 | }
128 | failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
129 | __strong __typeof(weakSelf)strongSelf = weakSelf;
130 | if ([strongSelf isActiveTaskURLEqualToURLRequest:request]) {
131 | if (failure) {
132 | failure(request, response, error);
133 | }
134 | strongSelf.af_activeImageDownloadReceipt = nil;
135 | }
136 | }];
137 |
138 | self.af_activeImageDownloadReceipt = receipt;
139 | }
140 | }
141 |
142 | - (void)cancelImageDownloadTask {
143 | if (self.af_activeImageDownloadReceipt != nil) {
144 | [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt];
145 | self.af_activeImageDownloadReceipt = nil;
146 | }
147 | }
148 |
149 | - (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest {
150 | return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
151 | }
152 |
153 | @end
154 |
155 | #endif
156 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIKit+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #if TARGET_OS_IOS || TARGET_OS_TV
24 | #import
25 |
26 | #ifndef _UIKIT_AFNETWORKING_
27 | #define _UIKIT_AFNETWORKING_
28 |
29 | #if TARGET_OS_IOS
30 | #import "AFAutoPurgingImageCache.h"
31 | #import "AFImageDownloader.h"
32 | #import "AFNetworkActivityIndicatorManager.h"
33 | #import "UIRefreshControl+AFNetworking.h"
34 | #import "UIWebView+AFNetworking.h"
35 | #endif
36 |
37 | #import "UIActivityIndicatorView+AFNetworking.h"
38 | #import "UIButton+AFNetworking.h"
39 | #import "UIImageView+AFNetworking.h"
40 | #import "UIProgressView+AFNetworking.h"
41 | #endif /* _UIKIT_AFNETWORKING_ */
42 | #endif
43 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task.
35 | */
36 | @interface UIProgressView (AFNetworking)
37 |
38 | ///------------------------------------
39 | /// @name Setting Session Task Progress
40 | ///------------------------------------
41 |
42 | /**
43 | Binds the progress to the upload progress of the specified session task.
44 |
45 | @param task The session task.
46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
47 | */
48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
49 | animated:(BOOL)animated;
50 |
51 | /**
52 | Binds the progress to the download progress of the specified session task.
53 |
54 | @param task The session task.
55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
56 | */
57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
58 | animated:(BOOL)animated;
59 |
60 | @end
61 |
62 | NS_ASSUME_NONNULL_END
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIProgressView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIProgressView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import "AFURLSessionManager.h"
29 |
30 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext;
31 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext;
32 |
33 | #pragma mark -
34 |
35 | @implementation UIProgressView (AFNetworking)
36 |
37 | - (BOOL)af_uploadProgressAnimated {
38 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue];
39 | }
40 |
41 | - (void)af_setUploadProgressAnimated:(BOOL)animated {
42 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
43 | }
44 |
45 | - (BOOL)af_downloadProgressAnimated {
46 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue];
47 | }
48 |
49 | - (void)af_setDownloadProgressAnimated:(BOOL)animated {
50 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
51 | }
52 |
53 | #pragma mark -
54 |
55 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
56 | animated:(BOOL)animated
57 | {
58 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
59 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
60 |
61 | [self af_setUploadProgressAnimated:animated];
62 | }
63 |
64 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
65 | animated:(BOOL)animated
66 | {
67 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
68 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
69 |
70 | [self af_setDownloadProgressAnimated:animated];
71 | }
72 |
73 | #pragma mark - NSKeyValueObserving
74 |
75 | - (void)observeValueForKeyPath:(NSString *)keyPath
76 | ofObject:(id)object
77 | change:(__unused NSDictionary *)change
78 | context:(void *)context
79 | {
80 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
81 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
82 | if ([object countOfBytesExpectedToSend] > 0) {
83 | dispatch_async(dispatch_get_main_queue(), ^{
84 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
85 | });
86 | }
87 | }
88 |
89 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
90 | if ([object countOfBytesExpectedToReceive] > 0) {
91 | dispatch_async(dispatch_get_main_queue(), ^{
92 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
93 | });
94 | }
95 | }
96 |
97 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
98 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
99 | @try {
100 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
101 |
102 | if (context == AFTaskCountOfBytesSentContext) {
103 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
104 | }
105 |
106 | if (context == AFTaskCountOfBytesReceivedContext) {
107 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
108 | }
109 | }
110 | @catch (NSException * __unused exception) {}
111 | }
112 | }
113 | }
114 | }
115 |
116 | @end
117 |
118 | #endif
119 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if TARGET_OS_IOS
28 |
29 | #import
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task.
35 | */
36 | @interface UIRefreshControl (AFNetworking)
37 |
38 | ///-----------------------------------
39 | /// @name Refreshing for Session Tasks
40 | ///-----------------------------------
41 |
42 | /**
43 | Binds the refreshing state to the state of the specified task.
44 |
45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
46 | */
47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
48 |
49 | @end
50 |
51 | NS_ASSUME_NONNULL_END
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIRefreshControl+AFNetworking.h"
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import "AFURLSessionManager.h"
29 |
30 | @interface AFRefreshControlNotificationObserver : NSObject
31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl;
32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl;
33 |
34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
35 |
36 | @end
37 |
38 | @implementation UIRefreshControl (AFNetworking)
39 |
40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver {
41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
42 | if (notificationObserver == nil) {
43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self];
44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
45 | }
46 | return notificationObserver;
47 | }
48 |
49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task];
51 | }
52 |
53 | @end
54 |
55 | @implementation AFRefreshControlNotificationObserver
56 |
57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl
58 | {
59 | self = [super init];
60 | if (self) {
61 | _refreshControl = refreshControl;
62 | }
63 | return self;
64 | }
65 |
66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
68 |
69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
72 |
73 | if (task) {
74 | #pragma clang diagnostic push
75 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
76 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
77 | if (task.state == NSURLSessionTaskStateRunning) {
78 | [self.refreshControl beginRefreshing];
79 |
80 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
81 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
82 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
83 | } else {
84 | [self.refreshControl endRefreshing];
85 | }
86 | #pragma clang diagnostic pop
87 | }
88 | }
89 |
90 | #pragma mark -
91 |
92 | - (void)af_beginRefreshing {
93 | dispatch_async(dispatch_get_main_queue(), ^{
94 | #pragma clang diagnostic push
95 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
96 | [self.refreshControl beginRefreshing];
97 | #pragma clang diagnostic pop
98 | });
99 | }
100 |
101 | - (void)af_endRefreshing {
102 | dispatch_async(dispatch_get_main_queue(), ^{
103 | #pragma clang diagnostic push
104 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
105 | [self.refreshControl endRefreshing];
106 | #pragma clang diagnostic pop
107 | });
108 | }
109 |
110 | #pragma mark -
111 |
112 | - (void)dealloc {
113 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
114 |
115 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
116 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
118 | }
119 |
120 | @end
121 |
122 | #endif
123 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFHTTPSessionManager;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.
36 |
37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly.
38 | */
39 | @interface UIWebView (AFNetworking)
40 |
41 | /**
42 | The session manager used to download all requests.
43 | */
44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
45 |
46 | /**
47 | Asynchronously loads the specified request.
48 |
49 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
50 | @param progress A progress object monitoring the current download progress.
51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
53 | */
54 | - (void)loadRequest:(NSURLRequest *)request
55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
57 | failure:(nullable void (^)(NSError *error))failure;
58 |
59 | /**
60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
61 |
62 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
65 | @param progress A progress object monitoring the current download progress.
66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
68 | */
69 | - (void)loadRequest:(NSURLRequest *)request
70 | MIMEType:(nullable NSString *)MIMEType
71 | textEncodingName:(nullable NSString *)textEncodingName
72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
74 | failure:(nullable void (^)(NSError *error))failure;
75 |
76 | @end
77 |
78 | NS_ASSUME_NONNULL_END
79 |
80 | #endif
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/AFNetworking3.0/UIKit+AFNetworking/UIWebView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIWebView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import "AFHTTPSessionManager.h"
29 | #import "AFURLResponseSerialization.h"
30 | #import "AFURLRequestSerialization.h"
31 |
32 | @interface UIWebView (_AFNetworking)
33 | @property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask;
34 | @end
35 |
36 | @implementation UIWebView (_AFNetworking)
37 |
38 | - (NSURLSessionDataTask *)af_URLSessionTask {
39 | return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask));
40 | }
41 |
42 | - (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask {
43 | objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 | }
45 |
46 | @end
47 |
48 | #pragma mark -
49 |
50 | @implementation UIWebView (AFNetworking)
51 |
52 | - (AFHTTPSessionManager *)sessionManager {
53 | static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil;
54 | static dispatch_once_t onceToken;
55 | dispatch_once(&onceToken, ^{
56 | _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
57 | _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
58 | _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
59 | });
60 |
61 | #pragma clang diagnostic push
62 | #pragma clang diagnostic ignored "-Wgnu"
63 | return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager;
64 | #pragma clang diagnostic pop
65 | }
66 |
67 | - (void)setSessionManager:(AFHTTPSessionManager *)sessionManager {
68 | objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
69 | }
70 |
71 | - (AFHTTPResponseSerializer *)responseSerializer {
72 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil;
73 | static dispatch_once_t onceToken;
74 | dispatch_once(&onceToken, ^{
75 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer];
76 | });
77 |
78 | #pragma clang diagnostic push
79 | #pragma clang diagnostic ignored "-Wgnu"
80 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer;
81 | #pragma clang diagnostic pop
82 | }
83 |
84 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
85 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
86 | }
87 |
88 | #pragma mark -
89 |
90 | - (void)loadRequest:(NSURLRequest *)request
91 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
92 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
93 | failure:(void (^)(NSError *error))failure
94 | {
95 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) {
96 | NSStringEncoding stringEncoding = NSUTF8StringEncoding;
97 | if (response.textEncodingName) {
98 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
99 | if (encoding != kCFStringEncodingInvalidId) {
100 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
101 | }
102 | }
103 |
104 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding];
105 | if (success) {
106 | string = success(response, string);
107 | }
108 |
109 | return [string dataUsingEncoding:stringEncoding];
110 | } failure:failure];
111 | }
112 |
113 | - (void)loadRequest:(NSURLRequest *)request
114 | MIMEType:(NSString *)MIMEType
115 | textEncodingName:(NSString *)textEncodingName
116 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
117 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
118 | failure:(void (^)(NSError *error))failure
119 | {
120 | NSParameterAssert(request);
121 |
122 | if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) {
123 | [self.af_URLSessionTask cancel];
124 | }
125 | self.af_URLSessionTask = nil;
126 |
127 | __weak __typeof(self)weakSelf = self;
128 | NSURLSessionDataTask *dataTask;
129 | dataTask = [self.sessionManager
130 | GET:request.URL.absoluteString
131 | parameters:nil
132 | success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
133 | __strong __typeof(weakSelf) strongSelf = weakSelf;
134 | if (success) {
135 | success((NSHTTPURLResponse *)task.response, responseObject);
136 | }
137 | [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]];
138 |
139 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
140 | [strongSelf.delegate webViewDidFinishLoad:strongSelf];
141 | }
142 | }
143 | failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
144 | if (failure) {
145 | failure(error);
146 | }
147 | }];
148 | self.af_URLSessionTask = dataTask;
149 | *progress = [self.sessionManager progressForDataTask:dataTask];
150 | [self.af_URLSessionTask resume];
151 |
152 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
153 | [self.delegate webViewDidStartLoad:self];
154 | }
155 | }
156 |
157 | @end
158 |
159 | #endif
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | /**
13 | * A group of MASConstraint objects
14 | */
15 | @interface MASCompositeConstraint : MASConstraint
16 |
17 | /**
18 | * Creates a composite with a predefined array of children
19 | *
20 | * @param children child MASConstraints
21 | *
22 | * @return a composite constraint
23 | */
24 | - (id)initWithChildren:(NSArray *)children;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASCompositeConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASCompositeConstraint.h"
10 | #import "MASConstraint+Private.h"
11 |
12 | @interface MASCompositeConstraint ()
13 |
14 | @property (nonatomic, strong) id mas_key;
15 | @property (nonatomic, strong) NSMutableArray *childConstraints;
16 |
17 | @end
18 |
19 | @implementation MASCompositeConstraint
20 |
21 | - (id)initWithChildren:(NSArray *)children {
22 | self = [super init];
23 | if (!self) return nil;
24 |
25 | _childConstraints = [children mutableCopy];
26 | for (MASConstraint *constraint in _childConstraints) {
27 | constraint.delegate = self;
28 | }
29 |
30 | return self;
31 | }
32 |
33 | #pragma mark - MASConstraintDelegate
34 |
35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
36 | NSUInteger index = [self.childConstraints indexOfObject:constraint];
37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint];
39 | }
40 |
41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
42 | id strongDelegate = self.delegate;
43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
44 | newConstraint.delegate = self;
45 | [self.childConstraints addObject:newConstraint];
46 | return newConstraint;
47 | }
48 |
49 | #pragma mark - NSLayoutConstraint multiplier proxies
50 |
51 | - (MASConstraint * (^)(CGFloat))multipliedBy {
52 | return ^id(CGFloat multiplier) {
53 | for (MASConstraint *constraint in self.childConstraints) {
54 | constraint.multipliedBy(multiplier);
55 | }
56 | return self;
57 | };
58 | }
59 |
60 | - (MASConstraint * (^)(CGFloat))dividedBy {
61 | return ^id(CGFloat divider) {
62 | for (MASConstraint *constraint in self.childConstraints) {
63 | constraint.dividedBy(divider);
64 | }
65 | return self;
66 | };
67 | }
68 |
69 | #pragma mark - MASLayoutPriority proxy
70 |
71 | - (MASConstraint * (^)(MASLayoutPriority))priority {
72 | return ^id(MASLayoutPriority priority) {
73 | for (MASConstraint *constraint in self.childConstraints) {
74 | constraint.priority(priority);
75 | }
76 | return self;
77 | };
78 | }
79 |
80 | #pragma mark - NSLayoutRelation proxy
81 |
82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
83 | return ^id(id attr, NSLayoutRelation relation) {
84 | for (MASConstraint *constraint in self.childConstraints.copy) {
85 | constraint.equalToWithRelation(attr, relation);
86 | }
87 | return self;
88 | };
89 | }
90 |
91 | #pragma mark - attribute chaining
92 |
93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
95 | return self;
96 | }
97 |
98 | #pragma mark - Animator proxy
99 |
100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
101 |
102 | - (MASConstraint *)animator {
103 | for (MASConstraint *constraint in self.childConstraints) {
104 | [constraint animator];
105 | }
106 | return self;
107 | }
108 |
109 | #endif
110 |
111 | #pragma mark - debug helpers
112 |
113 | - (MASConstraint * (^)(id))key {
114 | return ^id(id key) {
115 | self.mas_key = key;
116 | int i = 0;
117 | for (MASConstraint *constraint in self.childConstraints) {
118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]);
119 | }
120 | return self;
121 | };
122 | }
123 |
124 | #pragma mark - NSLayoutConstraint constant setters
125 |
126 | - (void)setInsets:(MASEdgeInsets)insets {
127 | for (MASConstraint *constraint in self.childConstraints) {
128 | constraint.insets = insets;
129 | }
130 | }
131 |
132 | - (void)setOffset:(CGFloat)offset {
133 | for (MASConstraint *constraint in self.childConstraints) {
134 | constraint.offset = offset;
135 | }
136 | }
137 |
138 | - (void)setSizeOffset:(CGSize)sizeOffset {
139 | for (MASConstraint *constraint in self.childConstraints) {
140 | constraint.sizeOffset = sizeOffset;
141 | }
142 | }
143 |
144 | - (void)setCenterOffset:(CGPoint)centerOffset {
145 | for (MASConstraint *constraint in self.childConstraints) {
146 | constraint.centerOffset = centerOffset;
147 | }
148 | }
149 |
150 | #pragma mark - MASConstraint
151 |
152 | - (void)activate {
153 | for (MASConstraint *constraint in self.childConstraints) {
154 | [constraint activate];
155 | }
156 | }
157 |
158 | - (void)deactivate {
159 | for (MASConstraint *constraint in self.childConstraints) {
160 | [constraint deactivate];
161 | }
162 | }
163 |
164 | - (void)install {
165 | for (MASConstraint *constraint in self.childConstraints) {
166 | constraint.updateExisting = self.updateExisting;
167 | [constraint install];
168 | }
169 | }
170 |
171 | - (void)uninstall {
172 | for (MASConstraint *constraint in self.childConstraints) {
173 | [constraint uninstall];
174 | }
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint+Private.h
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 29/04/14.
6 | // Copyright (c) 2014 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 |
11 | @protocol MASConstraintDelegate;
12 |
13 |
14 | @interface MASConstraint ()
15 |
16 | /**
17 | * Whether or not to check for an existing constraint instead of adding constraint
18 | */
19 | @property (nonatomic, assign) BOOL updateExisting;
20 |
21 | /**
22 | * Usually MASConstraintMaker but could be a parent MASConstraint
23 | */
24 | @property (nonatomic, weak) id delegate;
25 |
26 | /**
27 | * Based on a provided value type, is equal to calling:
28 | * NSNumber - setOffset:
29 | * NSValue with CGPoint - setPointOffset:
30 | * NSValue with CGSize - setSizeOffset:
31 | * NSValue with MASEdgeInsets - setInsets:
32 | */
33 | - (void)setLayoutConstantWithValue:(NSValue *)value;
34 |
35 | @end
36 |
37 |
38 | @interface MASConstraint (Abstract)
39 |
40 | /**
41 | * Sets the constraint relation to given NSLayoutRelation
42 | * returns a block which accepts one of the following:
43 | * MASViewAttribute, UIView, NSValue, NSArray
44 | * see readme for more details.
45 | */
46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
47 |
48 | /**
49 | * Override to set a custom chaining behaviour
50 | */
51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
52 |
53 | @end
54 |
55 |
56 | @protocol MASConstraintDelegate
57 |
58 | /**
59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
61 | */
62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
63 |
64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * Enables Constraints to be created with chainable syntax
13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint)
14 | * or a group of NSLayoutConstraints (MASComposisteConstraint)
15 | */
16 | @interface MASConstraint : NSObject
17 |
18 | // Chaining Support
19 |
20 | /**
21 | * Modifies the NSLayoutConstraint constant,
22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
24 | */
25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets;
26 |
27 | /**
28 | * Modifies the NSLayoutConstraint constant,
29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
31 | */
32 | - (MASConstraint * (^)(CGSize offset))sizeOffset;
33 |
34 | /**
35 | * Modifies the NSLayoutConstraint constant,
36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
38 | */
39 | - (MASConstraint * (^)(CGPoint offset))centerOffset;
40 |
41 | /**
42 | * Modifies the NSLayoutConstraint constant
43 | */
44 | - (MASConstraint * (^)(CGFloat offset))offset;
45 |
46 | /**
47 | * Modifies the NSLayoutConstraint constant based on a value type
48 | */
49 | - (MASConstraint * (^)(NSValue *value))valueOffset;
50 |
51 | /**
52 | * Sets the NSLayoutConstraint multiplier property
53 | */
54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
55 |
56 | /**
57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy
58 | */
59 | - (MASConstraint * (^)(CGFloat divider))dividedBy;
60 |
61 | /**
62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority
63 | */
64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority;
65 |
66 | /**
67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow
68 | */
69 | - (MASConstraint * (^)())priorityLow;
70 |
71 | /**
72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium
73 | */
74 | - (MASConstraint * (^)())priorityMedium;
75 |
76 | /**
77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh
78 | */
79 | - (MASConstraint * (^)())priorityHigh;
80 |
81 | /**
82 | * Sets the constraint relation to NSLayoutRelationEqual
83 | * returns a block which accepts one of the following:
84 | * MASViewAttribute, UIView, NSValue, NSArray
85 | * see readme for more details.
86 | */
87 | - (MASConstraint * (^)(id attr))equalTo;
88 |
89 | /**
90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual
91 | * returns a block which accepts one of the following:
92 | * MASViewAttribute, UIView, NSValue, NSArray
93 | * see readme for more details.
94 | */
95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo;
96 |
97 | /**
98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual
99 | * returns a block which accepts one of the following:
100 | * MASViewAttribute, UIView, NSValue, NSArray
101 | * see readme for more details.
102 | */
103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo;
104 |
105 | /**
106 | * Optional semantic property which has no effect but improves the readability of constraint
107 | */
108 | - (MASConstraint *)with;
109 |
110 | /**
111 | * Optional semantic property which has no effect but improves the readability of constraint
112 | */
113 | - (MASConstraint *)and;
114 |
115 | /**
116 | * Creates a new MASCompositeConstraint with the called attribute and reciever
117 | */
118 | - (MASConstraint *)left;
119 | - (MASConstraint *)top;
120 | - (MASConstraint *)right;
121 | - (MASConstraint *)bottom;
122 | - (MASConstraint *)leading;
123 | - (MASConstraint *)trailing;
124 | - (MASConstraint *)width;
125 | - (MASConstraint *)height;
126 | - (MASConstraint *)centerX;
127 | - (MASConstraint *)centerY;
128 | - (MASConstraint *)baseline;
129 |
130 | #if TARGET_OS_IPHONE || TARGET_OS_TV
131 |
132 | - (MASConstraint *)leftMargin;
133 | - (MASConstraint *)rightMargin;
134 | - (MASConstraint *)topMargin;
135 | - (MASConstraint *)bottomMargin;
136 | - (MASConstraint *)leadingMargin;
137 | - (MASConstraint *)trailingMargin;
138 | - (MASConstraint *)centerXWithinMargins;
139 | - (MASConstraint *)centerYWithinMargins;
140 |
141 | #endif
142 |
143 |
144 | /**
145 | * Sets the constraint debug name
146 | */
147 | - (MASConstraint * (^)(id key))key;
148 |
149 | // NSLayoutConstraint constant Setters
150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks
151 |
152 | /**
153 | * Modifies the NSLayoutConstraint constant,
154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
156 | */
157 | - (void)setInsets:(MASEdgeInsets)insets;
158 |
159 | /**
160 | * Modifies the NSLayoutConstraint constant,
161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
163 | */
164 | - (void)setSizeOffset:(CGSize)sizeOffset;
165 |
166 | /**
167 | * Modifies the NSLayoutConstraint constant,
168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
170 | */
171 | - (void)setCenterOffset:(CGPoint)centerOffset;
172 |
173 | /**
174 | * Modifies the NSLayoutConstraint constant
175 | */
176 | - (void)setOffset:(CGFloat)offset;
177 |
178 |
179 | // NSLayoutConstraint Installation support
180 |
181 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
182 | /**
183 | * Whether or not to go through the animator proxy when modifying the constraint
184 | */
185 | @property (nonatomic, copy, readonly) MASConstraint *animator;
186 | #endif
187 |
188 | /**
189 | * Activates an NSLayoutConstraint if it's supported by an OS.
190 | * Invokes install otherwise.
191 | */
192 | - (void)activate;
193 |
194 | /**
195 | * Deactivates previously installed/activated NSLayoutConstraint.
196 | */
197 | - (void)deactivate;
198 |
199 | /**
200 | * Creates a NSLayoutConstraint and adds it to the appropriate view.
201 | */
202 | - (void)install;
203 |
204 | /**
205 | * Removes previously installed NSLayoutConstraint
206 | */
207 | - (void)uninstall;
208 |
209 | @end
210 |
211 |
212 | /**
213 | * Convenience auto-boxing macros for MASConstraint methods.
214 | *
215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
216 | * A potential drawback of this is that the unprefixed macros will appear in global scope.
217 | */
218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__)))
219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
221 |
222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__)))
223 |
224 |
225 | #ifdef MAS_SHORTHAND_GLOBALS
226 |
227 | #define equalTo(...) mas_equalTo(__VA_ARGS__)
228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__)
229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__)
230 |
231 | #define offset(...) mas_offset(__VA_ARGS__)
232 |
233 | #endif
234 |
235 |
236 | @interface MASConstraint (AutoboxingSupport)
237 |
238 | /**
239 | * Aliases to corresponding relation methods (for shorthand macros)
240 | * Also needed to aid autocompletion
241 | */
242 | - (MASConstraint * (^)(id attr))mas_equalTo;
243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo;
244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo;
245 |
246 | /**
247 | * A dummy method to aid autocompletion
248 | */
249 | - (MASConstraint * (^)(id offset))mas_offset;
250 |
251 | @end
252 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.m
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 1/20/14.
6 | //
7 |
8 | #import "MASConstraint.h"
9 | #import "MASConstraint+Private.h"
10 |
11 | #define MASMethodNotImplemented() \
12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \
13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \
14 | userInfo:nil]
15 |
16 | @implementation MASConstraint
17 |
18 | #pragma mark - Init
19 |
20 | - (id)init {
21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly.");
22 | return [super init];
23 | }
24 |
25 | #pragma mark - NSLayoutRelation proxies
26 |
27 | - (MASConstraint * (^)(id))equalTo {
28 | return ^id(id attribute) {
29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
30 | };
31 | }
32 |
33 | - (MASConstraint * (^)(id))mas_equalTo {
34 | return ^id(id attribute) {
35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
36 | };
37 | }
38 |
39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo {
40 | return ^id(id attribute) {
41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
42 | };
43 | }
44 |
45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo {
46 | return ^id(id attribute) {
47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
48 | };
49 | }
50 |
51 | - (MASConstraint * (^)(id))lessThanOrEqualTo {
52 | return ^id(id attribute) {
53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
54 | };
55 | }
56 |
57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo {
58 | return ^id(id attribute) {
59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
60 | };
61 | }
62 |
63 | #pragma mark - MASLayoutPriority proxies
64 |
65 | - (MASConstraint * (^)())priorityLow {
66 | return ^id{
67 | self.priority(MASLayoutPriorityDefaultLow);
68 | return self;
69 | };
70 | }
71 |
72 | - (MASConstraint * (^)())priorityMedium {
73 | return ^id{
74 | self.priority(MASLayoutPriorityDefaultMedium);
75 | return self;
76 | };
77 | }
78 |
79 | - (MASConstraint * (^)())priorityHigh {
80 | return ^id{
81 | self.priority(MASLayoutPriorityDefaultHigh);
82 | return self;
83 | };
84 | }
85 |
86 | #pragma mark - NSLayoutConstraint constant proxies
87 |
88 | - (MASConstraint * (^)(MASEdgeInsets))insets {
89 | return ^id(MASEdgeInsets insets){
90 | self.insets = insets;
91 | return self;
92 | };
93 | }
94 |
95 | - (MASConstraint * (^)(CGSize))sizeOffset {
96 | return ^id(CGSize offset) {
97 | self.sizeOffset = offset;
98 | return self;
99 | };
100 | }
101 |
102 | - (MASConstraint * (^)(CGPoint))centerOffset {
103 | return ^id(CGPoint offset) {
104 | self.centerOffset = offset;
105 | return self;
106 | };
107 | }
108 |
109 | - (MASConstraint * (^)(CGFloat))offset {
110 | return ^id(CGFloat offset){
111 | self.offset = offset;
112 | return self;
113 | };
114 | }
115 |
116 | - (MASConstraint * (^)(NSValue *value))valueOffset {
117 | return ^id(NSValue *offset) {
118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
119 | [self setLayoutConstantWithValue:offset];
120 | return self;
121 | };
122 | }
123 |
124 | - (MASConstraint * (^)(id offset))mas_offset {
125 | // Will never be called due to macro
126 | return nil;
127 | }
128 |
129 | #pragma mark - NSLayoutConstraint constant setter
130 |
131 | - (void)setLayoutConstantWithValue:(NSValue *)value {
132 | if ([value isKindOfClass:NSNumber.class]) {
133 | self.offset = [(NSNumber *)value doubleValue];
134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) {
135 | CGPoint point;
136 | [value getValue:&point];
137 | self.centerOffset = point;
138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) {
139 | CGSize size;
140 | [value getValue:&size];
141 | self.sizeOffset = size;
142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) {
143 | MASEdgeInsets insets;
144 | [value getValue:&insets];
145 | self.insets = insets;
146 | } else {
147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value);
148 | }
149 | }
150 |
151 | #pragma mark - Semantic properties
152 |
153 | - (MASConstraint *)with {
154 | return self;
155 | }
156 |
157 | - (MASConstraint *)and {
158 | return self;
159 | }
160 |
161 | #pragma mark - Chaining
162 |
163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute {
164 | MASMethodNotImplemented();
165 | }
166 |
167 | - (MASConstraint *)left {
168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
169 | }
170 |
171 | - (MASConstraint *)top {
172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
173 | }
174 |
175 | - (MASConstraint *)right {
176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
177 | }
178 |
179 | - (MASConstraint *)bottom {
180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
181 | }
182 |
183 | - (MASConstraint *)leading {
184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
185 | }
186 |
187 | - (MASConstraint *)trailing {
188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
189 | }
190 |
191 | - (MASConstraint *)width {
192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
193 | }
194 |
195 | - (MASConstraint *)height {
196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
197 | }
198 |
199 | - (MASConstraint *)centerX {
200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
201 | }
202 |
203 | - (MASConstraint *)centerY {
204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
205 | }
206 |
207 | - (MASConstraint *)baseline {
208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
209 | }
210 |
211 | #if TARGET_OS_IPHONE || TARGET_OS_TV
212 |
213 | - (MASConstraint *)leftMargin {
214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
215 | }
216 |
217 | - (MASConstraint *)rightMargin {
218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
219 | }
220 |
221 | - (MASConstraint *)topMargin {
222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
223 | }
224 |
225 | - (MASConstraint *)bottomMargin {
226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
227 | }
228 |
229 | - (MASConstraint *)leadingMargin {
230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
231 | }
232 |
233 | - (MASConstraint *)trailingMargin {
234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
235 | }
236 |
237 | - (MASConstraint *)centerXWithinMargins {
238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
239 | }
240 |
241 | - (MASConstraint *)centerYWithinMargins {
242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
243 | }
244 |
245 | #endif
246 |
247 | #pragma mark - Abstract
248 |
249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); }
250 |
251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); }
252 |
253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); }
254 |
255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); }
256 |
257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); }
258 |
259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); }
260 |
261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); }
262 |
263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); }
264 |
265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); }
266 |
267 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
268 |
269 | - (MASConstraint *)animator { MASMethodNotImplemented(); }
270 |
271 | #endif
272 |
273 | - (void)activate { MASMethodNotImplemented(); }
274 |
275 | - (void)deactivate { MASMethodNotImplemented(); }
276 |
277 | - (void)install { MASMethodNotImplemented(); }
278 |
279 | - (void)uninstall { MASMethodNotImplemented(); }
280 |
281 | @end
282 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | typedef NS_OPTIONS(NSInteger, MASAttribute) {
13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft,
14 | MASAttributeRight = 1 << NSLayoutAttributeRight,
15 | MASAttributeTop = 1 << NSLayoutAttributeTop,
16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom,
17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading,
18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth,
20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight,
21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24 |
25 | #if TARGET_OS_IPHONE || TARGET_OS_TV
26 |
27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin,
29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin,
30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin,
31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,
35 |
36 | #endif
37 |
38 | };
39 |
40 | /**
41 | * Provides factory methods for creating MASConstraints.
42 | * Constraints are collected until they are ready to be installed
43 | *
44 | */
45 | @interface MASConstraintMaker : NSObject
46 |
47 | /**
48 | * The following properties return a new MASViewConstraint
49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute
50 | */
51 | @property (nonatomic, strong, readonly) MASConstraint *left;
52 | @property (nonatomic, strong, readonly) MASConstraint *top;
53 | @property (nonatomic, strong, readonly) MASConstraint *right;
54 | @property (nonatomic, strong, readonly) MASConstraint *bottom;
55 | @property (nonatomic, strong, readonly) MASConstraint *leading;
56 | @property (nonatomic, strong, readonly) MASConstraint *trailing;
57 | @property (nonatomic, strong, readonly) MASConstraint *width;
58 | @property (nonatomic, strong, readonly) MASConstraint *height;
59 | @property (nonatomic, strong, readonly) MASConstraint *centerX;
60 | @property (nonatomic, strong, readonly) MASConstraint *centerY;
61 | @property (nonatomic, strong, readonly) MASConstraint *baseline;
62 |
63 | #if TARGET_OS_IPHONE || TARGET_OS_TV
64 |
65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin;
66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin;
67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin;
68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin;
69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin;
70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin;
71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins;
72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins;
73 |
74 | #endif
75 |
76 | /**
77 | * Returns a block which creates a new MASCompositeConstraint with the first item set
78 | * to the makers associated view and children corresponding to the set bits in the
79 | * MASAttribute parameter. Combine multiple attributes via binary-or.
80 | */
81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs);
82 |
83 | /**
84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges
85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right)
86 | * with the first item set to the makers associated view
87 | */
88 | @property (nonatomic, strong, readonly) MASConstraint *edges;
89 |
90 | /**
91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize
92 | * which generates the appropriate MASViewConstraint children (width, height)
93 | * with the first item set to the makers associated view
94 | */
95 | @property (nonatomic, strong, readonly) MASConstraint *size;
96 |
97 | /**
98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter
99 | * which generates the appropriate MASViewConstraint children (centerX, centerY)
100 | * with the first item set to the makers associated view
101 | */
102 | @property (nonatomic, strong, readonly) MASConstraint *center;
103 |
104 | /**
105 | * Whether or not to check for an existing constraint instead of adding constraint
106 | */
107 | @property (nonatomic, assign) BOOL updateExisting;
108 |
109 | /**
110 | * Whether or not to remove existing constraints prior to installing
111 | */
112 | @property (nonatomic, assign) BOOL removeExisting;
113 |
114 | /**
115 | * initialises the maker with a default view
116 | *
117 | * @param view any MASConstrait are created with this view as the first item
118 | *
119 | * @return a new MASConstraintMaker
120 | */
121 | - (id)initWithView:(MAS_VIEW *)view;
122 |
123 | /**
124 | * Calls install method on any MASConstraints which have been created by this maker
125 | *
126 | * @return an array of all the installed MASConstraints
127 | */
128 | - (NSArray *)install;
129 |
130 | - (MASConstraint * (^)(dispatch_block_t))group;
131 |
132 | @end
133 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * When you are debugging or printing the constraints attached to a view this subclass
13 | * makes it easier to identify which constraints have been created via Masonry
14 | */
15 | @interface MASLayoutConstraint : NSLayoutConstraint
16 |
17 | /**
18 | * a key to associate with this constraint
19 | */
20 | @property (nonatomic, strong) id mas_key;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASLayoutConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASLayoutConstraint.h"
10 |
11 | @implementation MASLayoutConstraint
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASUtilities.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASUtilities.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 19/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 |
13 | #if TARGET_OS_IPHONE || TARGET_OS_TV
14 |
15 | #import
16 | #define MAS_VIEW UIView
17 | #define MAS_VIEW_CONTROLLER UIViewController
18 | #define MASEdgeInsets UIEdgeInsets
19 |
20 | typedef UILayoutPriority MASLayoutPriority;
21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired;
22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh;
23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500;
24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow;
25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel;
26 |
27 | #elif TARGET_OS_MAC
28 |
29 | #import
30 | #define MAS_VIEW NSView
31 | #define MASEdgeInsets NSEdgeInsets
32 |
33 | typedef NSLayoutPriority MASLayoutPriority;
34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired;
35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh;
36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow;
37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501;
38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut;
39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow;
40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow;
41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression;
42 |
43 | #endif
44 |
45 | /**
46 | * Allows you to attach keys to objects matching the variable names passed.
47 | *
48 | * view1.mas_key = @"view1", view2.mas_key = @"view2";
49 | *
50 | * is equivalent to:
51 | *
52 | * MASAttachKeys(view1, view2);
53 | */
54 | #define MASAttachKeys(...) \
55 | { \
56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \
57 | for (id key in keyPairs.allKeys) { \
58 | id obj = keyPairs[key]; \
59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \
60 | @"Cannot attach mas_key to %@", obj); \
61 | [obj setMas_key:key]; \
62 | } \
63 | }
64 |
65 | /**
66 | * Used to create object hashes
67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html
68 | */
69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger))
70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch)))
71 |
72 | /**
73 | * Given a scalar or struct value, wraps it in NSValue
74 | * Based on EXPObjectify: https://github.com/specta/expecta
75 | */
76 | static inline id _MASBoxValue(const char *type, ...) {
77 | va_list v;
78 | va_start(v, type);
79 | id obj = nil;
80 | if (strcmp(type, @encode(id)) == 0) {
81 | id actual = va_arg(v, id);
82 | obj = actual;
83 | } else if (strcmp(type, @encode(CGPoint)) == 0) {
84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint);
85 | obj = [NSValue value:&actual withObjCType:type];
86 | } else if (strcmp(type, @encode(CGSize)) == 0) {
87 | CGSize actual = (CGSize)va_arg(v, CGSize);
88 | obj = [NSValue value:&actual withObjCType:type];
89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) {
90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets);
91 | obj = [NSValue value:&actual withObjCType:type];
92 | } else if (strcmp(type, @encode(double)) == 0) {
93 | double actual = (double)va_arg(v, double);
94 | obj = [NSNumber numberWithDouble:actual];
95 | } else if (strcmp(type, @encode(float)) == 0) {
96 | float actual = (float)va_arg(v, double);
97 | obj = [NSNumber numberWithFloat:actual];
98 | } else if (strcmp(type, @encode(int)) == 0) {
99 | int actual = (int)va_arg(v, int);
100 | obj = [NSNumber numberWithInt:actual];
101 | } else if (strcmp(type, @encode(long)) == 0) {
102 | long actual = (long)va_arg(v, long);
103 | obj = [NSNumber numberWithLong:actual];
104 | } else if (strcmp(type, @encode(long long)) == 0) {
105 | long long actual = (long long)va_arg(v, long long);
106 | obj = [NSNumber numberWithLongLong:actual];
107 | } else if (strcmp(type, @encode(short)) == 0) {
108 | short actual = (short)va_arg(v, int);
109 | obj = [NSNumber numberWithShort:actual];
110 | } else if (strcmp(type, @encode(char)) == 0) {
111 | char actual = (char)va_arg(v, int);
112 | obj = [NSNumber numberWithChar:actual];
113 | } else if (strcmp(type, @encode(bool)) == 0) {
114 | bool actual = (bool)va_arg(v, int);
115 | obj = [NSNumber numberWithBool:actual];
116 | } else if (strcmp(type, @encode(unsigned char)) == 0) {
117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int);
118 | obj = [NSNumber numberWithUnsignedChar:actual];
119 | } else if (strcmp(type, @encode(unsigned int)) == 0) {
120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int);
121 | obj = [NSNumber numberWithUnsignedInt:actual];
122 | } else if (strcmp(type, @encode(unsigned long)) == 0) {
123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long);
124 | obj = [NSNumber numberWithUnsignedLong:actual];
125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) {
126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long);
127 | obj = [NSNumber numberWithUnsignedLongLong:actual];
128 | } else if (strcmp(type, @encode(unsigned short)) == 0) {
129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int);
130 | obj = [NSNumber numberWithUnsignedShort:actual];
131 | }
132 | va_end(v);
133 | return obj;
134 | }
135 |
136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value))
137 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | //
2 | // Masonry.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Masonry.
12 | FOUNDATION_EXPORT double MasonryVersionNumber;
13 |
14 | //! Project version string for Masonry.
15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
16 |
17 | #import "MASUtilities.h"
18 | #import "View+MASAdditions.h"
19 | #import "View+MASShorthandAdditions.h"
20 | #import "ViewController+MASAdditions.h"
21 | #import "NSArray+MASAdditions.h"
22 | #import "NSArray+MASShorthandAdditions.h"
23 | #import "MASConstraint.h"
24 | #import "MASCompositeConstraint.h"
25 | #import "MASViewAttribute.h"
26 | #import "MASViewConstraint.h"
27 | #import "MASConstraintMaker.h"
28 | #import "MASLayoutConstraint.h"
29 | #import "NSLayoutConstraint+MASDebugAdditions.h"
30 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/NSArray+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.m
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 | #import "View+MASAdditions.h"
11 |
12 | @implementation NSArray (MASAdditions)
13 |
14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block {
15 | NSMutableArray *constraints = [NSMutableArray array];
16 | for (MAS_VIEW *view in self) {
17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]];
19 | }
20 | return constraints;
21 | }
22 |
23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block {
24 | NSMutableArray *constraints = [NSMutableArray array];
25 | for (MAS_VIEW *view in self) {
26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]];
28 | }
29 | return constraints;
30 | }
31 |
32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block {
33 | NSMutableArray *constraints = [NSMutableArray array];
34 | for (MAS_VIEW *view in self) {
35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]];
37 | }
38 | return constraints;
39 | }
40 |
41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
42 | if (self.count < 2) {
43 | NSAssert(self.count>1,@"views to distribute need to bigger than one");
44 | return;
45 | }
46 |
47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
48 | if (axisType == MASAxisTypeHorizontal) {
49 | MAS_VIEW *prev;
50 | for (int i = 0; i < self.count; i++) {
51 | MAS_VIEW *v = self[i];
52 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
53 | if (prev) {
54 | make.width.equalTo(prev);
55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing);
56 | if (i == (CGFloat)self.count - 1) {//last one
57 | make.right.equalTo(tempSuperView).offset(-tailSpacing);
58 | }
59 | }
60 | else {//first one
61 | make.left.equalTo(tempSuperView).offset(leadSpacing);
62 | }
63 |
64 | }];
65 | prev = v;
66 | }
67 | }
68 | else {
69 | MAS_VIEW *prev;
70 | for (int i = 0; i < self.count; i++) {
71 | MAS_VIEW *v = self[i];
72 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
73 | if (prev) {
74 | make.height.equalTo(prev);
75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing);
76 | if (i == (CGFloat)self.count - 1) {//last one
77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
78 | }
79 | }
80 | else {//first one
81 | make.top.equalTo(tempSuperView).offset(leadSpacing);
82 | }
83 |
84 | }];
85 | prev = v;
86 | }
87 | }
88 | }
89 |
90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
91 | if (self.count < 2) {
92 | NSAssert(self.count>1,@"views to distribute need to bigger than one");
93 | return;
94 | }
95 |
96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
97 | if (axisType == MASAxisTypeHorizontal) {
98 | MAS_VIEW *prev;
99 | for (int i = 0; i < self.count; i++) {
100 | MAS_VIEW *v = self[i];
101 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
102 | if (prev) {
103 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
104 | make.width.equalTo(@(fixedItemLength));
105 | if (i == (CGFloat)self.count - 1) {//last one
106 | make.right.equalTo(tempSuperView).offset(-tailSpacing);
107 | }
108 | else {
109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
110 | }
111 | }
112 | else {//first one
113 | make.left.equalTo(tempSuperView).offset(leadSpacing);
114 | make.width.equalTo(@(fixedItemLength));
115 | }
116 | }];
117 | prev = v;
118 | }
119 | }
120 | else {
121 | MAS_VIEW *prev;
122 | for (int i = 0; i < self.count; i++) {
123 | MAS_VIEW *v = self[i];
124 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
125 | if (prev) {
126 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
127 | make.height.equalTo(@(fixedItemLength));
128 | if (i == (CGFloat)self.count - 1) {//last one
129 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
130 | }
131 | else {
132 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
133 | }
134 | }
135 | else {//first one
136 | make.top.equalTo(tempSuperView).offset(leadSpacing);
137 | make.height.equalTo(@(fixedItemLength));
138 | }
139 | }];
140 | prev = v;
141 | }
142 | }
143 | }
144 |
145 | - (MAS_VIEW *)mas_commonSuperviewOfViews
146 | {
147 | MAS_VIEW *commonSuperview = nil;
148 | MAS_VIEW *previousView = nil;
149 | for (id object in self) {
150 | if ([object isKindOfClass:[MAS_VIEW class]]) {
151 | MAS_VIEW *view = (MAS_VIEW *)object;
152 | if (previousView) {
153 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview];
154 | } else {
155 | commonSuperview = view;
156 | }
157 | previousView = view;
158 | }
159 | }
160 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy.");
161 | return commonSuperview;
162 | }
163 |
164 | @end
165 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand array additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface NSArray (MASShorthandAdditions)
18 |
19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
22 |
23 | @end
24 |
25 | @implementation NSArray (MASShorthandAdditions)
26 |
27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
28 | return [self mas_makeConstraints:block];
29 | }
30 |
31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
32 | return [self mas_updateConstraints:block];
33 | }
34 |
35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
36 | return [self mas_remakeConstraints:block];
37 | }
38 |
39 | @end
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * makes debug and log output of NSLayoutConstraints more readable
13 | */
14 | @interface NSLayoutConstraint (MASDebugAdditions)
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/NSLayoutConstraint+MASDebugAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSLayoutConstraint+MASDebugAdditions.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 |
13 | @implementation NSLayoutConstraint (MASDebugAdditions)
14 |
15 | #pragma mark - description maps
16 |
17 | + (NSDictionary *)layoutRelationDescriptionsByValue {
18 | static dispatch_once_t once;
19 | static NSDictionary *descriptionMap;
20 | dispatch_once(&once, ^{
21 | descriptionMap = @{
22 | @(NSLayoutRelationEqual) : @"==",
23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=",
24 | @(NSLayoutRelationLessThanOrEqual) : @"<=",
25 | };
26 | });
27 | return descriptionMap;
28 | }
29 |
30 | + (NSDictionary *)layoutAttributeDescriptionsByValue {
31 | static dispatch_once_t once;
32 | static NSDictionary *descriptionMap;
33 | dispatch_once(&once, ^{
34 | descriptionMap = @{
35 | @(NSLayoutAttributeTop) : @"top",
36 | @(NSLayoutAttributeLeft) : @"left",
37 | @(NSLayoutAttributeBottom) : @"bottom",
38 | @(NSLayoutAttributeRight) : @"right",
39 | @(NSLayoutAttributeLeading) : @"leading",
40 | @(NSLayoutAttributeTrailing) : @"trailing",
41 | @(NSLayoutAttributeWidth) : @"width",
42 | @(NSLayoutAttributeHeight) : @"height",
43 | @(NSLayoutAttributeCenterX) : @"centerX",
44 | @(NSLayoutAttributeCenterY) : @"centerY",
45 | @(NSLayoutAttributeBaseline) : @"baseline",
46 |
47 | #if TARGET_OS_IPHONE || TARGET_OS_TV
48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin",
49 | @(NSLayoutAttributeRightMargin) : @"rightMargin",
50 | @(NSLayoutAttributeTopMargin) : @"topMargin",
51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin",
52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin",
53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin",
54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins",
55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins",
56 | #endif
57 |
58 | };
59 |
60 | });
61 | return descriptionMap;
62 | }
63 |
64 |
65 | + (NSDictionary *)layoutPriorityDescriptionsByValue {
66 | static dispatch_once_t once;
67 | static NSDictionary *descriptionMap;
68 | dispatch_once(&once, ^{
69 | #if TARGET_OS_IPHONE || TARGET_OS_TV
70 | descriptionMap = @{
71 | @(MASLayoutPriorityDefaultHigh) : @"high",
72 | @(MASLayoutPriorityDefaultLow) : @"low",
73 | @(MASLayoutPriorityDefaultMedium) : @"medium",
74 | @(MASLayoutPriorityRequired) : @"required",
75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size",
76 | };
77 | #elif TARGET_OS_MAC
78 | descriptionMap = @{
79 | @(MASLayoutPriorityDefaultHigh) : @"high",
80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window",
81 | @(MASLayoutPriorityDefaultMedium) : @"medium",
82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put",
83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window",
84 | @(MASLayoutPriorityDefaultLow) : @"low",
85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size",
86 | @(MASLayoutPriorityRequired) : @"required",
87 | };
88 | #endif
89 | });
90 | return descriptionMap;
91 | }
92 |
93 | #pragma mark - description override
94 |
95 | + (NSString *)descriptionForObject:(id)obj {
96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) {
97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]];
98 | }
99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj];
100 | }
101 |
102 | - (NSString *)description {
103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"];
104 |
105 | [description appendString:[self.class descriptionForObject:self]];
106 |
107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
109 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
110 | }
111 |
112 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
113 |
114 | if (self.secondItem) {
115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
116 | }
117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
118 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
119 | }
120 |
121 | if (self.multiplier != 1) {
122 | [description appendFormat:@" * %g", self.multiplier];
123 | }
124 |
125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) {
126 | [description appendFormat:@" %g", self.constant];
127 | } else {
128 | if (self.constant) {
129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)];
130 | }
131 | }
132 |
133 | if (self.priority != MASLayoutPriorityRequired) {
134 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
135 | }
136 |
137 | [description appendString:@">"];
138 | return description;
139 | }
140 |
141 | @end
142 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | /**
14 | * Provides constraint maker block
15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs
16 | */
17 | @interface MAS_VIEW (MASAdditions)
18 |
19 | /**
20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute
21 | */
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom;
26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading;
27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing;
28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width;
29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height;
30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX;
31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY;
32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline;
33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr);
34 |
35 | #if TARGET_OS_IPHONE || TARGET_OS_TV
36 |
37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
45 |
46 | #endif
47 |
48 | /**
49 | * a key to associate with this view
50 | */
51 | @property (nonatomic, strong) id mas_key;
52 |
53 | /**
54 | * Finds the closest common superview between this view and another view
55 | *
56 | * @param view other view
57 | *
58 | * @return returns nil if common superview could not be found
59 | */
60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
61 |
62 | /**
63 | * Creates a MASConstraintMaker with the callee view.
64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing
65 | *
66 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
67 | *
68 | * @return Array of created MASConstraints
69 | */
70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block;
71 |
72 | /**
73 | * Creates a MASConstraintMaker with the callee view.
74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
75 | * If an existing constraint exists then it will be updated instead.
76 | *
77 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
78 | *
79 | * @return Array of created/updated MASConstraints
80 | */
81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block;
82 |
83 | /**
84 | * Creates a MASConstraintMaker with the callee view.
85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
86 | * All constraints previously installed for the view will be removed.
87 | *
88 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
89 | *
90 | * @return Array of created/updated MASConstraints
91 | */
92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block;
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/View+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "View+MASAdditions.h"
10 | #import
11 |
12 | @implementation MAS_VIEW (MASAdditions)
13 |
14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block {
15 | self.translatesAutoresizingMaskIntoConstraints = NO;
16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
17 | block(constraintMaker);
18 | return [constraintMaker install];
19 | }
20 |
21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block {
22 | self.translatesAutoresizingMaskIntoConstraints = NO;
23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
24 | constraintMaker.updateExisting = YES;
25 | block(constraintMaker);
26 | return [constraintMaker install];
27 | }
28 |
29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block {
30 | self.translatesAutoresizingMaskIntoConstraints = NO;
31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
32 | constraintMaker.removeExisting = YES;
33 | block(constraintMaker);
34 | return [constraintMaker install];
35 | }
36 |
37 | #pragma mark - NSLayoutAttribute properties
38 |
39 | - (MASViewAttribute *)mas_left {
40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft];
41 | }
42 |
43 | - (MASViewAttribute *)mas_top {
44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop];
45 | }
46 |
47 | - (MASViewAttribute *)mas_right {
48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight];
49 | }
50 |
51 | - (MASViewAttribute *)mas_bottom {
52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom];
53 | }
54 |
55 | - (MASViewAttribute *)mas_leading {
56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading];
57 | }
58 |
59 | - (MASViewAttribute *)mas_trailing {
60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing];
61 | }
62 |
63 | - (MASViewAttribute *)mas_width {
64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth];
65 | }
66 |
67 | - (MASViewAttribute *)mas_height {
68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight];
69 | }
70 |
71 | - (MASViewAttribute *)mas_centerX {
72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX];
73 | }
74 |
75 | - (MASViewAttribute *)mas_centerY {
76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY];
77 | }
78 |
79 | - (MASViewAttribute *)mas_baseline {
80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline];
81 | }
82 |
83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute
84 | {
85 | return ^(NSLayoutAttribute attr) {
86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr];
87 | };
88 | }
89 |
90 | #if TARGET_OS_IPHONE || TARGET_OS_TV
91 |
92 | - (MASViewAttribute *)mas_leftMargin {
93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin];
94 | }
95 |
96 | - (MASViewAttribute *)mas_rightMargin {
97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin];
98 | }
99 |
100 | - (MASViewAttribute *)mas_topMargin {
101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin];
102 | }
103 |
104 | - (MASViewAttribute *)mas_bottomMargin {
105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin];
106 | }
107 |
108 | - (MASViewAttribute *)mas_leadingMargin {
109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin];
110 | }
111 |
112 | - (MASViewAttribute *)mas_trailingMargin {
113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin];
114 | }
115 |
116 | - (MASViewAttribute *)mas_centerXWithinMargins {
117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins];
118 | }
119 |
120 | - (MASViewAttribute *)mas_centerYWithinMargins {
121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
122 | }
123 |
124 | #endif
125 |
126 | #pragma mark - associated properties
127 |
128 | - (id)mas_key {
129 | return objc_getAssociatedObject(self, @selector(mas_key));
130 | }
131 |
132 | - (void)setMas_key:(id)key {
133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
134 | }
135 |
136 | #pragma mark - heirachy
137 |
138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
139 | MAS_VIEW *closestCommonSuperview = nil;
140 |
141 | MAS_VIEW *secondViewSuperview = view;
142 | while (!closestCommonSuperview && secondViewSuperview) {
143 | MAS_VIEW *firstViewSuperview = self;
144 | while (!closestCommonSuperview && firstViewSuperview) {
145 | if (secondViewSuperview == firstViewSuperview) {
146 | closestCommonSuperview = secondViewSuperview;
147 | }
148 | firstViewSuperview = firstViewSuperview.superview;
149 | }
150 | secondViewSuperview = secondViewSuperview.superview;
151 | }
152 | return closestCommonSuperview;
153 | }
154 |
155 | @end
156 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "View+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand view additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface MAS_VIEW (MASShorthandAdditions)
18 |
19 | @property (nonatomic, strong, readonly) MASViewAttribute *left;
20 | @property (nonatomic, strong, readonly) MASViewAttribute *top;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *right;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *width;
26 | @property (nonatomic, strong, readonly) MASViewAttribute *height;
27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX;
28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY;
29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline;
30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr);
31 |
32 | #if TARGET_OS_IPHONE || TARGET_OS_TV
33 |
34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin;
36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin;
37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin;
38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin;
39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin;
40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins;
41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins;
42 |
43 | #endif
44 |
45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
48 |
49 | @end
50 |
51 | #define MAS_ATTR_FORWARD(attr) \
52 | - (MASViewAttribute *)attr { \
53 | return [self mas_##attr]; \
54 | }
55 |
56 | @implementation MAS_VIEW (MASShorthandAdditions)
57 |
58 | MAS_ATTR_FORWARD(top);
59 | MAS_ATTR_FORWARD(left);
60 | MAS_ATTR_FORWARD(bottom);
61 | MAS_ATTR_FORWARD(right);
62 | MAS_ATTR_FORWARD(leading);
63 | MAS_ATTR_FORWARD(trailing);
64 | MAS_ATTR_FORWARD(width);
65 | MAS_ATTR_FORWARD(height);
66 | MAS_ATTR_FORWARD(centerX);
67 | MAS_ATTR_FORWARD(centerY);
68 | MAS_ATTR_FORWARD(baseline);
69 |
70 | #if TARGET_OS_IPHONE || TARGET_OS_TV
71 |
72 | MAS_ATTR_FORWARD(leftMargin);
73 | MAS_ATTR_FORWARD(rightMargin);
74 | MAS_ATTR_FORWARD(topMargin);
75 | MAS_ATTR_FORWARD(bottomMargin);
76 | MAS_ATTR_FORWARD(leadingMargin);
77 | MAS_ATTR_FORWARD(trailingMargin);
78 | MAS_ATTR_FORWARD(centerXWithinMargins);
79 | MAS_ATTR_FORWARD(centerYWithinMargins);
80 |
81 | #endif
82 |
83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
84 | return [self mas_attribute];
85 | }
86 |
87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
88 | return [self mas_makeConstraints:block];
89 | }
90 |
91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
92 | return [self mas_updateConstraints:block];
93 | }
94 |
95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
96 | return [self mas_remakeConstraints:block];
97 | }
98 |
99 | @end
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | #ifdef MAS_VIEW_CONTROLLER
14 |
15 | @interface MAS_VIEW_CONTROLLER (MASAdditions)
16 |
17 | /**
18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
19 | */
20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom;
26 |
27 |
28 | @end
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/ThreePart/Masonry/ViewController+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "ViewController+MASAdditions.h"
10 |
11 | #ifdef MAS_VIEW_CONTROLLER
12 |
13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions)
14 |
15 | - (MASViewAttribute *)mas_topLayoutGuide {
16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
17 | }
18 | - (MASViewAttribute *)mas_topLayoutGuideTop {
19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
20 | }
21 | - (MASViewAttribute *)mas_topLayoutGuideBottom {
22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
23 | }
24 |
25 | - (MASViewAttribute *)mas_bottomLayoutGuide {
26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
27 | }
28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop {
29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
30 | }
31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom {
32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
33 | }
34 |
35 |
36 |
37 | @end
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/UIView+Category/UIView+GetViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+GetViewController.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIView (GetViewController)
12 |
13 | // 获取当前view所在的ViewController
14 | - (UIViewController *)theViewController;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/UIView+Category/UIView+GetViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+GetViewController.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "UIView+GetViewController.h"
10 |
11 | @implementation UIView (GetViewController)
12 |
13 | - (UIViewController *)theViewController {
14 | for (UIView* next = [self superview]; next; next = next.superview) {
15 | UIResponder *nextResponder = [next nextResponder];
16 | if ([nextResponder isKindOfClass:[UIViewController class]]) {
17 | return (UIViewController *)nextResponder;
18 | }
19 | }
20 | return nil;
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/UIviewController+Category/UIViewController+AlertVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+AlertVC.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIViewController (AlertVC)
12 |
13 | // 经过几秒后自动消失的AlertController
14 | - (void)showTheAlertView:(UIViewController *)vc andAfterDissmiss:(NSInteger)time title:(NSString *)title message:(NSString *)message;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/UIviewController+Category/UIViewController+AlertVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+AlertVC.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/10.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "UIViewController+AlertVC.h"
10 |
11 | @implementation UIViewController (AlertVC)
12 |
13 | - (void)showTheAlertView:(UIViewController *)vc andAfterDissmiss:(NSInteger)time title:(NSString *)title message:(NSString *)message
14 | {
15 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
16 | [vc presentViewController:alertC animated:YES completion:^{
17 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
18 | [alertC dismissViewControllerAnimated:YES completion:nil];
19 | });
20 | }];
21 |
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/images/back.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/LDXKit/images/back.jpg
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/images/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/LDXKit/images/login.png
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/images/pass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/LDXKit/images/pass.png
--------------------------------------------------------------------------------
/iOS-PHP/php/LDXKit/images/zhenxiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/LDXKit/images/zhenxiang.png
--------------------------------------------------------------------------------
/iOS-PHP/php/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/11.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 | @property (nonatomic, strong) NSDictionary *dic;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/iOS-PHP/php/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/3/11.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 |
11 | @interface MainViewController ()
12 |
13 | @end
14 |
15 | @implementation MainViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 |
21 | UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(50, 100, 200, 200)];
22 | imageV.backgroundColor = [UIColor greenColor];
23 |
24 | // 取出用户名对应的头部图片
25 | NSString *imageValue = self.dic[@"name"];
26 |
27 | #warning 5. 直接在这里进行网址路径拼接, 因为不同用户要取不同的头像图片, 图片都保存在服务器的一个叫download2文件夹, 里面图片是根据用户名加.jpg来获取的
28 | NSString *url = [NSString stringWithFormat:@"%@/%@.jpg", @"http://127.0.0.1/download2", imageValue];
29 |
30 | // 同步加载图片
31 | NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
32 | UIImage *image = [UIImage imageWithData:data];
33 | [imageV setImage:image];
34 | [self.view addSubview:imageV];
35 |
36 | // 循环创建label, 从请求下来传过来的字典里, 拿出指定的字段的value值显示
37 | NSArray *arr = @[@"name", @"age", @"telephone"];
38 | for (int i = 0; i < 3; i++) {
39 | CGFloat offY = 320;
40 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 320 + i * 50, 250, 40)];
41 | [self.view addSubview:label];
42 | NSString *s = arr[i];
43 | NSString *value = self.dic[s];
44 | label.text = [NSString stringWithFormat:@"%@: %@", s, value];
45 |
46 | }
47 |
48 |
49 | }
50 |
51 | - (void)didReceiveMemoryWarning {
52 | [super didReceiveMemoryWarning];
53 | // Dispose of any resources that can be recreated.
54 | }
55 |
56 | /*
57 | #pragma mark - Navigation
58 |
59 | // In a storyboard-based application, you will often want to do a little preparation before navigation
60 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
61 | // Get the new view controller using [segue destinationViewController].
62 | // Pass the selected object to the new view controller.
63 | }
64 | */
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/iOS-PHP/php/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // php
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/iOS-PHP/php/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "MainViewController.h"
11 | #import "Define.h"
12 |
13 |
14 |
15 |
16 |
17 | #warning 大家可以参考我的微博:
18 | //http://www.cnblogs.com/lidongxu/p/5256330.html
19 |
20 |
21 | @interface ViewController ()
22 | @property (nonatomic, strong) LoginView *loginR;
23 | @end
24 |
25 | @implementation ViewController
26 |
27 | - (void)viewDidLoad {
28 | [super viewDidLoad];
29 |
30 | self.view.backgroundColor = [UIColor greenColor];
31 |
32 | self.view.layer.cornerRadius = 40;
33 |
34 | #warning 1. 创建登录注册页面
35 | // 登录注册类调用
36 | self.loginR = [[LoginView alloc] initWithFrame:self.view.frame];
37 | #warning 2. 签代理 代理方法可以拿到登录信息和注册信息
38 | _loginR.delegate = self;
39 | [self.view addSubview:_loginR];
40 |
41 | }
42 |
43 | #pragma mark - LoginView delegate
44 | #warning 3. 根据不同的后台给的字段 代表的意思 以及值进行不同处理
45 | - (void)getLoginName:(NSString *)name pass:(NSString *)pass
46 | {
47 | // 调用登录验证接口 (这里用get网络请求的方式, 和post网络请求的方式)
48 | NSString *url = @"http://127.0.0.1/loginGet.php";
49 | // 后台规定登录用户名的字段必须是name密码的pass
50 | NSDictionary *dic = @{@"name":name, @"pass":pass};
51 | // 网络请求有点特殊 点进去看
52 | [LDXNetWork GetThePHPWithURL:url par:dic success:^(id responseObject) {
53 | // 后台返回的字典里 如果success对应的value是1代表登录成功
54 | if ([responseObject[@"success"] isEqualToString:@"1"]) {
55 | MainViewController *mainVC = [[MainViewController alloc] init];
56 | mainVC.dic = responseObject;
57 | [self presentViewController:mainVC animated:YES completion:nil];
58 | }
59 | else {
60 | [self showTheAlertView:self andAfterDissmiss:1.0 title:@"账号或密码错误" message:@""];
61 | }
62 |
63 |
64 | } error:^(NSError *error) {
65 | NSLog(@"%@", error);
66 | }];
67 |
68 |
69 | }
70 |
71 | - (void)getRegisterName:(NSString *)name pass:(NSString *)pass age:(NSString *)age telephone:(NSString *)telephone image:(UIImage *)image
72 | {
73 |
74 | NSString *url = @"http://127.0.0.1/register.php";
75 | NSDictionary *dic = @{@"name2":name, @"pass2":pass, @"age2":age, @"telephone2":telephone};
76 | // 网络请求有点特殊点进去看 (@"uploadimageFile" 后台给的字段)
77 | [LDXNetWork PostThePHPWithURL:url par:dic image:image uploadName:@"uploadimageFile" success:^(id response) {
78 |
79 | NSString *success = response[@"success"];
80 | if ([success isEqualToString:@"1"]) {
81 | // 代表注册成功
82 | [self showTheAlertView:self andAfterDissmiss:1.5 title:@"注册成功" message:@""];
83 | // 跳转回到登录界面
84 | [_loginR goToLoginView];
85 |
86 | }
87 | else if([success isEqualToString:@"-1"]){
88 | [self showTheAlertView:self andAfterDissmiss:1.5 title:@"账号已经被注册了" message:@""];
89 | }
90 |
91 | } error:^(NSError *error) {
92 | NSLog(@"%@", error);
93 | }];
94 | }
95 |
96 |
97 | - (void)didReceiveMemoryWarning {
98 | [super didReceiveMemoryWarning];
99 | // Dispose of any resources that can be recreated.
100 | }
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/iOS-PHP/php/ceshi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/ceshi
--------------------------------------------------------------------------------
/iOS-PHP/php/hello.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lidongxuwork/upLoadImage-OC/d0b6658b8e920cf4a5cca52cd7f015e0583be599/iOS-PHP/php/hello.jpg
--------------------------------------------------------------------------------
/iOS-PHP/php/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // php
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOS-PHP/phpTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-PHP/phpTests/phpTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // phpTests.m
3 | // phpTests
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface phpTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation phpTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/iOS-PHP/phpUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS-PHP/phpUITests/phpUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // phpUITests.m
3 | // phpUITests
4 | //
5 | // Created by 李东旭 on 16/2/25.
6 | // Copyright © 2016年 李东旭. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface phpUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation phpUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------