Skip to content

Commit 5917e08

Browse files
committed
add swift demo
1 parent 430ea6d commit 5917e08

File tree

22 files changed

+1392
-1
lines changed

22 files changed

+1392
-1
lines changed

QiniuDemo/QiniuDemo/ViewController.m

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "Configure.h" // 测试参数配置,暂时只有token,可删除
1010
#import "ViewController.h"
1111
#import "QNTransactionManager.h"
12+
#import <Photos/Photos.h>
1213

1314
typedef NS_ENUM(NSInteger, UploadState){
1415
UploadStatePrepare,
@@ -102,7 +103,19 @@ - (void)uploadImageToQNFilePath:(NSString *)filePath {
102103
return weakSelf.uploadState == UploadStateCancelling;
103104
}];
104105

105-
[upManager putFile:filePath key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
106+
// [upManager putFile:filePath key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
107+
// NSLog(@"info ===== %@", info);
108+
// NSLog(@"resp ===== %@", resp);
109+
//
110+
// [weakSelf changeUploadState:UploadStatePrepare];
111+
// [weakSelf alertMessage:info.message];
112+
// }
113+
// option:uploadOption];
114+
115+
NSURL *url = [NSURL fileURLWithPath:filePath];
116+
PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
117+
PHAsset *asset = fetchResult.firstObject;
118+
[upManager putPHAsset:asset key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
106119
NSLog(@"info ===== %@", info);
107120
NSLog(@"resp ===== %@", resp);
108121

QiniuDemoOC/QiniuDemo.xcworkspace/contents.xcworkspacedata

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QiniuDemoSwift/Podfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Uncomment the next line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
target 'QiniuDemoSwift' do
5+
# Comment the next line if you don't want to use dynamic frameworks
6+
use_frameworks!
7+
pod 'Qiniu', :path => '../'
8+
pod 'ZLPhotoBrowser'
9+
10+
# Pods for QiniuDemoSwift
11+
12+
target 'QiniuDemoSwiftTests' do
13+
inherit! :search_paths
14+
# Pods for testing
15+
end
16+
17+
target 'QiniuDemoSwiftUITests' do
18+
# Pods for testing
19+
end
20+
21+
end

QiniuDemoSwift/QiniuDemoSwift.xcodeproj/project.pbxproj

+752
Large diffs are not rendered by default.

QiniuDemoSwift/QiniuDemoSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

QiniuDemoSwift/QiniuDemoSwift.xcworkspace/contents.xcworkspacedata

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// AppDelegate.swift
3+
// QiniuDemoSwift
4+
//
5+
// Created by yangsen on 2021/4/19.
6+
//
7+
8+
import UIKit
9+
10+
@main
11+
class AppDelegate: UIResponder, UIApplicationDelegate {
12+
13+
14+
15+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
16+
// Override point for customization after application launch.
17+
return true
18+
}
19+
20+
// MARK: UISceneSession Lifecycle
21+
22+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
23+
// Called when a new scene session is being created.
24+
// Use this method to select a configuration to create the new scene with.
25+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
26+
}
27+
28+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
29+
// Called when the user discards a scene session.
30+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
31+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
32+
}
33+
34+
35+
}
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
6+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<scenes>
11+
<!--View Controller-->
12+
<scene sceneID="tne-QT-ifu">
13+
<objects>
14+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="QiniuDemoSwift" customModuleProvider="target" sceneMemberID="viewController">
15+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
16+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
17+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18+
<subviews>
19+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="o8w-rP-uDU">
20+
<rect key="frame" x="157" y="652" width="100" height="40"/>
21+
<color key="backgroundColor" systemColor="systemPurpleColor"/>
22+
<constraints>
23+
<constraint firstAttribute="width" constant="100" id="yJM-CN-zEY"/>
24+
<constraint firstAttribute="height" constant="40" id="ymw-Eg-HHe"/>
25+
</constraints>
26+
<state key="normal" title="上传">
27+
<color key="titleColor" systemColor="systemBackgroundColor"/>
28+
</state>
29+
<connections>
30+
<action selector="upload:" destination="BYZ-38-t0r" eventType="touchUpInside" id="3xj-wb-hbg"/>
31+
</connections>
32+
</button>
33+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NqT-df-gdl">
34+
<rect key="frame" x="157" y="592" width="100" height="40"/>
35+
<color key="backgroundColor" systemColor="systemPurpleColor"/>
36+
<state key="normal" title="选择图片">
37+
<color key="titleColor" systemColor="systemBackgroundColor"/>
38+
</state>
39+
<connections>
40+
<action selector="selectImage:" destination="BYZ-38-t0r" eventType="touchUpInside" id="x9l-d5-yXg"/>
41+
</connections>
42+
</button>
43+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7hv-vG-fmM">
44+
<rect key="frame" x="41.5" y="359.5" width="331" height="177"/>
45+
<constraints>
46+
<constraint firstAttribute="width" secondItem="7hv-vG-fmM" secondAttribute="height" multiplier="15:8" id="7it-RD-rnr"/>
47+
</constraints>
48+
</imageView>
49+
</subviews>
50+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
51+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
52+
<constraints>
53+
<constraint firstItem="o8w-rP-uDU" firstAttribute="top" secondItem="NqT-df-gdl" secondAttribute="bottom" constant="20" id="0Vu-5A-S5y"/>
54+
<constraint firstItem="7hv-vG-fmM" firstAttribute="width" secondItem="8bC-Xf-vdC" secondAttribute="width" multiplier="0.8" id="AkB-uf-W7f"/>
55+
<constraint firstItem="o8w-rP-uDU" firstAttribute="width" secondItem="NqT-df-gdl" secondAttribute="width" id="GuW-e0-AUn"/>
56+
<constraint firstItem="NqT-df-gdl" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="UWG-yG-Ltk"/>
57+
<constraint firstItem="o8w-rP-uDU" firstAttribute="height" secondItem="NqT-df-gdl" secondAttribute="height" id="ZC1-xU-JoQ"/>
58+
<constraint firstItem="7hv-vG-fmM" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="ZHW-hE-jIp"/>
59+
<constraint firstItem="7hv-vG-fmM" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="b6d-9x-MDa"/>
60+
<constraint firstItem="o8w-rP-uDU" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="hHl-Mv-4Zq"/>
61+
<constraint firstItem="o8w-rP-uDU" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" multiplier="1.5" id="vFG-Kf-B4D"/>
62+
</constraints>
63+
</view>
64+
<connections>
65+
<outlet property="imageView" destination="7hv-vG-fmM" id="fDB-B8-Bpg"/>
66+
</connections>
67+
</viewController>
68+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
69+
</objects>
70+
<point key="canvasLocation" x="20" y="89"/>
71+
</scene>
72+
</scenes>
73+
<resources>
74+
<systemColor name="systemBackgroundColor">
75+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
76+
</systemColor>
77+
<systemColor name="systemPurpleColor">
78+
<color red="0.68627450980392157" green="0.32156862745098042" blue="0.87058823529411766" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
79+
</systemColor>
80+
</resources>
81+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Bridging_Header.h
3+
// QiniuDemoSwift
4+
//
5+
// Created by yangsen on 2021/4/20.
6+
//
7+
8+
#ifndef Bridging_Header_h
9+
#define Bridging_Header_h
10+
11+
12+
#endif /* Bridging_Header_h */

0 commit comments

Comments
 (0)